1

I need to send a POST request with a JSON object and a File in the same request with Content-Type: multipart/related. I could use Content-Type: multipart/form-data, but requirement asks for Content-Type: multipart/related.

Sample Request would be:

Content-Type: multipart/related; boundary=Example_boundary_37464 Content-Length: 2001 ... --Example_boundary_37464 Content-Type: application/json Content-Description: json

{ "name": "Test123", "firstname": "TestFirstName", "lastname": "TestLastName" }

--Example_boundary_37464 Content-Type: application/pdf Content-Transfer-Encoding: base64 Content-Description: document

VGhlIFBsZWRnZSBvZiBBbGxlZ2lhbmNlIHRvIHRoZSBGbGFnOiCTSSBwbGVkZ2UgYWxsZWdpYW5j ZSB0byB0aGUgRmxhZyBvZiB0aGUgVW5pdGVkIFN0YXRlcyBvZiBBbWVyaWNhLCBhbmQgdG8gdGhl

--Example_boundary_37464

Any help would be greatly appreciated.

YHC
  • 75
  • 9

0 Answers0