I would like to send a HTTP POST request with multipart data to the server. I have both JSON and a file which I want to send in a single request. I know how to do it for a single file and a single JSON. Now, I have a list of JSONs with each JSON having its own file which I want to send in a single request as a multipart list. How can I do that?
This question is a pure HTTP question. I see similar questions here, but all which I looked into use some kind of a library. I want pure HTTP answer.
This is an example of a multipart request accepting single file and a single JSON:
POST https://server:23854/request HTTP/1.1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
----WebKitFormBoundary
Content-Disposition: form-data; name="graphicFile"; filename="file.name"
Content-Type: image/vnd.dwg
1
----WebKitFormBoundary
Content-Disposition: form-data; name="javaScriptObjectNotationData"
Content-Type: application/json
{
"isThisJSON": true
}
Now, how can I send 2 files and 2 JSONs without using different part names and while maintaining order, so that first file corresponds to the first JSON, and second file to the second JSON?
So, on server, I want to read graphicFile
part and javaScriptObjectNotationData
part as two lists where item 1 in graphicFile
part should correspond to item 1 in javaScriptObjectNotationData
part. How should pure HTTP request look like which would achieve this?