Setting different content-type for form fields in multipart/form-data

Hello all,
I am using the HTTP Request Wizard to upload a file along with Json to specify how the end-point will ‘process’ the file. I easily was able to perform the call in Postman, but not able to get a successful POST using the wizard. My issue is how the HTML body is formed. This is the request from Postman:

POST https://dev-irapi.<someurl>:8093//api/pages HTTP/1.1
Authorization: AccessToken ioJF/fQaWjYCqnQB1EwMykUYRsPsLm1S2sxoDNge+cblEHvf8PBNl0UIRa2JlrJfvvmL2BxiNR2Z5ysOLILr4v1oU/bRI0eYlhzZf9WerLzZEP7jCa8Em/veDqfAnum0FfF/def0TkoQfsEwncPsc42uxoZp7/IT9Ezn4THICyT8dLDIh8k/kLaMPaRBqbLQ9Y0Osgx5XPO4dF1BroVRDkmHoLs/rqD4FQon5B4PJWRDp+sBgf1mz2yMSNRKapcNVX/MfRrnMX46V5BTALgfaY43+7nV/zGNTP6HXPzSSlCSSgM70QyeqfsATEkWjiU3lQxMgzM9eswrkCt0dpRJzkX9sy9pErUrWNLyykVj5Hg0L1KZHuInHAmUQqquu+Qt1AKEypJ+5QjGEZWFrx4qjQ==
Postman-Token: 86b466e7-61ed-4a8d-a616-3f0320791ef1
Host: dev-irapi<someurl>:8093
Content-Type: multipart/form-data; boundary=--------------------------543593475052579094938196
Content-Length: 8180

----------------------------543593475052579094938196
Content-Disposition: form-data; name="PageCreateData"
Content-Type: application/json

{"docId": "138419615", "description": "Farm Renewal Rate Calc Pg6"}
----------------------------543593475052579094938196
Content-Disposition: form-data; name="image0"; filename="FarmRenewalRateCalculator.xlsx"
Content-Type: application/pdf

<binary data goes here>
----------------------------543593475052579094938196--

However, in the HTTP Request Wizard, I get this:

POST https://dev-irapi.<someurl>:8093/api/pages/ HTTP/1.1
Authorization: AccessToken ioJA/fQaWjYCqnQB1EwMyqg8IAXRnkli2QWJgnbCUPVbs0ygMzhj6m7HLDz+mHQYaLD7jrB72D+nxj2bvvbP9pdXNtVP+3HYpqgbo1/3MViKp4mSfrTbYy5D3K1mszKcei9plSu2xeQ+RZHVMnFjZal9RKOTKg4bg8+mPbcXvdSKdApwSw5omIK+0WunysUa3O44QcFhzCZi8tUF8Dwd9gftBEcC4occj/SyUPabedBJaXN5/CuRKBdosLqejCskn+xDQ7PRJ6X+ux3WYsmpgxNEpRj2lEDmfSYeqoRc2QWsGjfxfU2aeSJxsGpuJN2JD1ByKVJ542mNM1sgcCjIutDnnsHzVqI2zUBZhJjHncJz8/5BOq2RajLLSRLxFmtTPx356saLPkozSTr0pbvDdQ==
Accept: */*
User-Agent: RestSharp/106.15.0.0
Content-Type: multipart/form-data; boundary=---------3532A6F5-A8D1-430A-B915-E9FA4B53F4BE
Host: dev-irapi.<someurl>:8093
Content-Length: 8142
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

-----------DC9FC71D-FB70-45CC-888F-4415E18D7430
Content-Disposition: form-data; name="PageCreateData"

{"docId": "138419615", "description": "Farm Renewal Rate Calc Pg6"}
-----------DC9FC71D-FB70-45CC-888F-4415E18D7430
Content-Disposition: form-data; name="image0"; filename="FarmRenewalRateCalculator.xlsx"
Content-Type: application/octet-stream

<binary goes here>
-----------DC9FC71D-FB70-45CC-888F-4415E18D7430--

Here are the setting in the Wizard:

For the most part, the main difference is the Content-Type of the different form fields or “Parameters”. The first form part should be “application/json” and the binary file type should be “application/pdf”.

In the Wizard, on the other hand, the first form part that is “application/json” in Postman is not set at all, and the second binary file that is “application/pdf” in Postman is set to “application/octet-stream” in the wizard.

I think that may be the issue, but I really need a hand to figure out how to use the Wizard properly to define this request.

Any help would be greatly appreciated. Thanks!!

Does anyone have an idea on this issue?

@gustavo.cervelin , @loginerror @Cristian_Negulescu
can you have a look on this please

I am also stuck with similar kind of issue I tried with Invoke Code (using vb.net code but it seems didn’t work)

I have to pass Bearer Token as auth and some body data with file like below
image

Dim client As HttpClient = New HttpClient()
client.BaseAddress = New Uri(in_API)

client.DefaultRequestHeaders.Add(“authorization”, in_Authorization)
Dim request As MultipartFormDataContent = New MultipartFormDataContent()
request.Add(New StringContent(in_docID), “docId”)
request.Add(New StringContent(“[{“name”: “ABC Field”, “values”: [{“value”: “Indrajit”}]}]”), “fields”)
request.Add(New StreamContent(File.OpenRead(“C:\8A.docx”)), “file”, (New FileInfo(“C:\8A.docx”).Name))

I can confirm that this is currently not possible with the HTTP Request activity and you will have to use the Invoke Code to perform it.

We are considering future improvements to the HTTP Request activity, but with no specific timeline just yet.