cancel
Showing results for 
Search instead for 
Did you mean: 

Error while sending Image file using REST API

0 Kudos

Hi Expterts,

I am working on scenario where we are sending Image file to another system using Rest API. I have used below code.

//Read image content from BO and convert data binary data to string

var image : BinaryObject.content;
//Read image content
image = this.Attachment.Document.GetFirst().FileContent.BinaryObject.content;
if (!image.IsInitial())
{
Body = Binary.ToBase64String(image);

//Assign Body to files parameter
var content = "{\"files\":\"" +Body+"\"}";
var ws_result = WebServiceUtilities.ExecuteRESTService(ScenarioName, ServiceName, "POST", HttpResource,
URLParameter, HeaderParameter, "multipart/form-data" , content);

}}

I am getting below error below error message post call,

Content = {
"_id": "e67a9288-f193-4107-98d7-8a20267204fa",
"error": "Invalid request",
"error_description": "This service requires at least 1 file. Please put your file(s) into the `files` field of the POST request",

Please help me to resolve the issue. Thanks in Advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

JOSC_ITLAB
Participant
0 Kudos

Hi Vinay,

at the moment you are just sending Binary.content via the rest call.

Could you try:
var image : BinaryObject;

image = this.Attachment.Document.GetFirst().FileContent.BinaryObject;

In this way you are sending the complete binary object.

Please let me know if it worked I'm no expert in this area as well.

Kind Regards,

Johannes