Skip to main content

Notifications

Business Central forum
Unanswered

Error In Http Request

Posted on by 1,638

Hi Community!

I have developed a Confirm Dialogue box that pops up when a new record is inserted into the Sales Quote line items. Upon selecting /Yes/, I send an HTTP request to send the Item number in the logic app. While my logic app is working as expected the issue is when I send a second request for a different Item without refreshing the page or closing the sales quote page. In this case, I face the following error, Please refer to the screenprints of the code and error for more details.

CODE:

 

 trigger OnInsertRecord(BelowxRec: Boolean): Boolean

    begin

        DWEFQ.SetRange(NIIN, Rec./No./);

        if not DWEFQ.FindSet() then begin

            if Confirm('Do you wish to include historical data for the Item No %1?', true, Rec./No./) then begin

                //Fetch Selected Record - Item Number

             A_Content := '{ /No./: /' + Rec./No./ + '/ }';

                //Code for the call Logic App on the Action.

                A_HttpContent.WriteFrom(AMS_Content);

                A_HttpContent.GetHeaders(AMS_HttpHeaders);

                A_HttpHeaders.Clear();

                A_HttpHeaders.Add('Content-Type', 'application/Json');

                A_HttpRequestMessage.Content := AMS_HttpContent;

                A_HttpRequestMessage.SetRequestUri('My URL');

                A_HttpRequestMessage.Method := 'post';

                A_HttpClient.Send(AMS_HttpRequestMessage, AMS_HttpResponseMessage);

                A_HttpResponseMessage.Content().ReadAs(responseText);

 

                if not A_HttpResponseMessage.IsSuccessStatusCode() then

                    Message('Sorry! The data was not found for ' + Rec./No./)

                else

                    Message('The data has been received for ' + Rec./No./);

                // A_HttpContent.Clear();

                // A_HttpRequestMessage.Content.Clear();

                // A_HttpResponseMessage.Content.Clear();

                // A_HttpClient.Clear();

            end

            else

                Message('Thank you for confirming.');

        end;

 

Error:

 

 Can anyone give me a solution for this what can I do?

 

Thank you in advance!!

 

Categories:
  • Judy Profile Picture
    Judy Microsoft Employee on at
    Error In Http Request
    Hi Sir,
     
    Can you please try to clear all the variables (uri, http request, content, headers...) in the beginning of the loop to see if it can help.
     
     
    Best Regards,
    Judy

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Mohana Yadav!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,142 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,979 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans