Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Unanswered

Error In Http Request

(0) ShareShare
ReportReport
Posted on by 1,795

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!!

 

  • 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

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,661 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans