web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Problem with Repeated GET Calls to the same URI in a loop

(0) ShareShare
ReportReport
Posted on by 23

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
        ...
  • Val Gameiro Consulting LLC Profile Picture
    23 on at

    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.

  • Verified answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    Thank you for sharing final outcome of the issue. This helps others.

    Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 674 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 362 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 359 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans