I'm having a problem in BC, issuing a GET to the same URI inside a loop.
I'm downloading a statement from a bank, and the output is limited to 100 transactions at a time, so I have to use a pageNumber parameter. In Postman, I issue one, no problem, then issue the other, no problem.
In BC, it works fine the first time through the loop, but the second time always fails with no return error (RequestMessage comes back empty).
I'm using HttpClient, and doing a simple GET with 2 parameters, date and pageNumber. In Postman, I can run those in sequence with no problems.
I've been looking for a way to close the connection each time, but can't find a reference in AL to do it.
Anybody have any ideas?
HttpClient.DefaultRequestHeaders.Add('x-apikey', GenLedSet."API Key");
HttpClient.DefaultRequestHeaders.Add('Authorization', StrSubstNo('Bearer %1', GenLedSet."Access Token"));
HttpClient.DefaultRequestHeaders.Add('Accept', 'application/json');
RequestMessage.Method('GET');
RequestMessage.SetRequestUri(URI + '&pageNumber=' + Format(CurrPage));
if not HttpClient.Send(RequestMessage, ResponseMessage) then
...
Hello,
Thank you for sharing final outcome of the issue. This helps others.
Thank you.
The solution was to put System.Clear(HttpClient) and System.Clear(RequestMessage) and the setups inside the loop, so it clears and re-sets the variables every time.
Using HttpClient.Clear() did not work.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156