248
Views
5
Comments
[Multipart/form-data] Consuming a multipart/form-data REST service that expects multiple files
Question
multipart-form-data
Service icon
Forge asset by Kilian Hekhuis

Hello All, 

Our client is exposing multipart/form-data REST service, where one of the parts is a JSON and the other is a pdf file.
Postman request works fine as seen bellow, however we did not have success using the [Multipart/form-data] component on Outsystems.

Even though the "fundContract" key is an uploaded JSON file on Postman, on the application, the JSON is composed of the form attributes values entered by the client, only the "file" key is actually uploaded as illustrated below:

On the Service Action, to simulate the file upload for the JSON attributes, I converted the structure containing the form values to a JSON and then to Binary Data before appending to the "Parts" List:

Unfortunately, that did not work. I get an error that the attributes are wrong. I also tried to send the JSON as text as seen bellow, but no success.

Any thoughts on how to solve this? Any help appreciated.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Paulo,

I'll try to take a look later today or tomorrow.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Ok, you said that you get an error that "the attributes are wrong". Did you check the output of the JSONSerialize? Is it identical to the content of the JSON file you use in Postman?

2020-11-20 12-13-23
pvivacqua

Kilian Hekhuis wrote:

Ok, you said that you get an error that "the attributes are wrong". Did you check the output of the JSONSerialize? Is it identical to the content of the JSON file you use in Postman?

Hi Kilian, thanks very much for your reply. 

The output of the JSONSerialize is identical to the content of the JSON file I use in Postman.
The error message is returned by the webservice in JAVA.Unfortunately they are not able to tell me exactly which attributes are wrong or are not received, but analyzing the request, they seem to sent ok.

This is the Binary of the request. Removed the pdf content for visualizing purposes.

JSON File Content:

Thanks for the help again.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Well, that looks like it should, or not? Can you compare it against what Postman produces?

2020-11-20 12-13-23
pvivacqua

Kilian Hekhuis wrote:

Well, that looks like it should, or not? Can you compare it against what Postman produces?

I will try that. Thanks for the suggestion.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.