Skip to main content

Notifications

Announcements

No record found.

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

Unable to send form data type request from business central

(0) ShareShare
ReportReport
Posted on by 105
Hi All,
Please help me, I am unable to send request to rest api facing issue but from post man its working
if
       
         CR
:= 13;
        LF := 10;
        NewLine += '' + CR + LF;

        // Request.GetHeaders(ContentHeaderL);

        TempBlob.CreateOutStream(PayloadOutStream);
       PayloadOutStream.WriteText('Content-Disposition: form-data; name="NAME"' + NewLine);
        PayloadOutStream.WriteText(NewLine);
        PayloadOutStream.WriteText('Eric TestWS' + NewLine);
        PayloadOutStream.WriteText('multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' + NewLine);
        PayloadOutStream.WriteText(NewLine);
        TempBlob.CreateInStream(PayloadInStream);
        // Write all bytes from the request body stream.

        Content.WriteFrom(PayloadInStream);
        Content.GetHeaders(ContentHeaderL);
        ContentHeaderL.Clear();
        ContentHeaderL.Add('Content-Length', '4096'); // this is required I think but when I keep this line request is aborting otherwise is request is success with error in response
        ContentHeaderL.Add('Content-Type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
        ContentHeaderL.Add('X-Kount-Api-Key', 'tokenvalue');

        Request.Method := 'POST';
        Request.SetRequestUri('https://risk.test.kount.net');
        Request.GetHeaders(Requestheaders);
        Requestheaders.Clear();
        Requestheaders.Add('Host', 'risk.test.kount.net');
        Request.Content(Content);
        Client.Send(Request, Response);


  • Verified answer
    RE: Unable to send form data type request from business central

    Hi Mahesh.

    As you told in Linkedin, for content type instead of giving value as direct number, taken value from tempblob.length it resolved the issue

    Thanks,

  • RE: Unable to send form data type request from business central

    client.send(request,response).

    if I dont put content length then post man response and business central response is same, when I use content length in post man request is successful but in bc it is failing with below error message

  • Suggested answer
    Mahesh U Profile Picture
    Mahesh U 425 on at
    RE: Unable to send form data type request from business central

    Hi Venkatesh,

    At what line the debugger is stopping while getting this error? 

    Try to change the length from hard coded to using actual length and try. Thanks!

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,187 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,966 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans