Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Azure Function call

(0) ShareShare
ReportReport
Posted on by 1,554

Hello Experts,

I am just consuming an azure function URL and in return giving them the purchase order number:-

In my debugger, I am receiving an HTTP status code 500 error , don't know why 

pastedimage1648023348864v1.pngpastedimage1648658065916v1.png

Em I missing something here ??

Thanks,

TK

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Azure Function call

    Http status message 500 is internal server error. That should indicate that the problem is within the azure function and not really in your Business Central code.

    Here are some code i use for calling an azure function. I could see some differences around content and http headers

    procedure SendToAzure(Payload: text): Boolean;

       var

           Setup: Record Azuresetup;

           hclient: HttpClient;

           respons: HttpResponseMessage;

           Content: HttpContent;

           ContentHeaders: HttpHeaders;

       begin

           if not AzureSetup.FindFirst() then error('%1 is empty', AzureSetup.TableCaption);

           AzureSetup.TestField("Outgoing file url");

           Content.WriteFrom(Payload);

           Content.GetHeaders(ContentHeaders);

           ContentHeaders.Clear();

           ContentHeaders.Add('Content-Type', 'application/json');

           hclient.Post(BankSetup."Outgoing file url", Content, respons);

           if respons.IsSuccessStatusCode then begin

               exit(true);

           end else begin

               Message(format(respons.HttpStatusCode));

               exit(false);

           end;

       end;

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans