[Multipart/form-data] Consuming a multipart/form-data REST service that expects multiple files

Forge Component
(7)
Published on 2019-09-06 by João Barata
7 votes
Published on 2019-09-06 by João Barata

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.

Hi Paulo,

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

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?

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.

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

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.