Sending multipart/form-data content with Postman C

2019-03-26 14:23发布

问题:

I'm struggling with creating POST multipart/mixed request with Postman Chrome extension. I keep getting HTTP 500.

Already gone through this question, but sadly solution doesn't works for me.

Here is my curl request which works for me.

curl -H "Content-Type: multipart/form-data" -F "merchantLogo=@offerlogo-320-320.png; type=image/png" -F "merchantDetails=@merchant.json; type=application/json" -X PATCH localhost:5000/api/merchants/57035bda0c74362faf5937f2/details -i -v

And when I use Postman

I am getting such response

{"code": 500,
"message": "There was an error processing your request. It has been logged (ID 034bec7815baca2e)."}

Request headers being passed from postman.

Somehow, the merchantDetails are always being passed as null when calling from POSTMAN and is passed properly when making call from curl.

Any help would be much appreciated.

EDITED 1:

My request from POSTMAN copied as curl,

curl 'http://localhost:5000/api/merchants/5714d8e060b2a79e62227d1a/details' -X PATCH -H 'Pragma: no-cache' -H 'Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-GB,en-US;q=0.8,en;q=0.6' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36' -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryxRZ6VKzFV40ZFIsd' -H 'Accept: /' -H 'Cache-Control: no-cache' -H 'Cookie: JSESSIONID=1ofut8bbydk491k2s80i4rowed; JSESSIONID=yg4l9zpjs5oj1xaqnuo44ehp6' -H 'Connection: keep-alive' --data-binary $'------WebKitFormBoundaryxRZ6VKzFV40ZFIsd\r\nContent-Disposition: form-data; name="merchantDetails"; filename="merchant.json"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n------WebKitFormBoundaryxRZ6VKzFV40ZFIsd\r\nContent-Disposition: form-data; name="merchantLogo"; filename="offerlogo-320-320.png"\r\nContent-Type: image/png\r\n\r\n\r\n------WebKitFormBoundaryxRZ6VKzFV40ZFIsd--\r\n' --compressed