Skip to main content
Microsoft Dynamics NAV forum
Unanswered

Upload File by consuming REST web service

editSubscribe (0) ShareShare
ReportReport
Posted on by 940

Hi Everyone,

Can anyone share good example for upload file / send file by consuming external REST Web service ? 

My end point would be something like bellow

 myapi.com/.../upload

I have to pass three parameters, API Key, Workflowid and file. 

I wrote bellow code,

userFile := 'D:\Temp\Helvetia.pdf';

RequestURL := 'myapi.com/.../upload';

Req := '{"api_key":"5445989G98398fs3t5","workflow_id":"939925","userfile":"'+userFile+'"}';
Request.open(HTTP_POST_REQUEST,RequestURL,FALSE,'','');
Request.setRequestHeader('Content-Type','multipart/form-data');
Request.send(Req );
IF Request.status = 200 THEN
 MESSAGE(Request.responseText);

But I am getting error. But I try using SOAPUI, it worked. 

Can anyone help suggest good method to pass file by consuming external REST API


Thanks

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,066 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,585 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans