Hello everyone,
First time poster here. I have used the GitHub “endpoint model generator” solution to generate the DLL’s I need to allow my C# application to connect to our Acumatica instance with our extended endpoint and the RESTAPI dll’s (Acumatica.RESTClient.dll and Acumatica.RESTClient.ContractBasedApi.dll that get compiled along with my endpoint dll.
I am using Visual Studio 2022 and C#.
I have been unable as of yet to figure out why the authApi.Login() function just locks up the app.
This is the content of the request (that was put together by the Acumatica code) as it looks immediately before being passed to the Client.SendAsync(request) call that hangs up.
{Method: POST, RequestUri: 'https://<ouracumaticadomain>/AcumaticaERP1//entity/auth/login', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
Content-Type: application/json; charset=utf-8
}}
Content: {System.Net.Http.StringContent}
HasHeaders: false
Headers: {}
Method: {POST}
Options: {System.Net.Http.HttpRequestOptions}
Properties: {System.Net.Http.HttpRequestOptions}
RequestUri: {https://<ouracumaticadomain>/AcumaticaERP1//entity/auth/login}
Version: {1.1}
VersionPolicy: RequestVersionOrLower
_content: {System.Net.Http.StringContent}
_disposed: false
_headers: {}
_method: {POST}
_options: {System.Net.Http.HttpRequestOptions}
_requestUri: {https://<ouracumaticadomain>/AcumaticaERP1//entity/auth/login}
_sendStatus: 0
_version: {1.1}
_versionPolicy: RequestVersionOrLower
The only thing I have noted is that the credentials (and body) appear to not be present in the call:
Has anyone seen this issue, and if so, please advise on how to get past it. I’ve got all the other functions ready to be tested, I just can’t get logged in. I suspected the double-slash might be an issue in the URL but it’s not.
My code has the following:
var authApi = new AuthApi(APILoginUrl, requestInterceptor: RequestLogger.LogRequest, responseInterceptor: RequestLogger.LogResponse);
Credentials credentials = new Credentials(APIUserName,APIPassword,"","", "");
authApi.LogIn(credentials);
and I’ve even tried bypassing the credentials object and sending the uid and pwd directly in:
authApi.LogIn(APIUserName, APIPassword);
We only have one tenant, so the last 3 values are not required in the login credentials object.
The requestlogger is logging this:
-----------------------------------------
5/8/2024 2:53:09 PM
Request
Method: POST
URL: https://<ouracumaticadomain>/AcumaticaERP1//entity/auth/login
Body: {"name":"<ouruserid>","password":"<ourpassword>"}
-----------------------------------------
I can step into the LogIn code, but once it gets to the function in the ApiClient.cs:
public async Task<HttpResponseMessage> CallApiAsync(...)
it hits this line and hangs:
var response = await Client.SendAsync(request);
I can successfully connect to our instance using Postman and query objects - and the same credentials used in PostMan are the ones I have set into my code here that refuses to ever return from the await call.
Can anyone help?
Best answer by Dmitrii Naumov
View original