Reputation: 11773
Using curl, I am trying to POST multiple arbitrary XML documents to an endpoint that expects 1 or more documents (the specific goal here being to test "or more").
I have seen some SO answers suggest that using -F
(instead of -d
) with throwaway key names will instruct curl to generate the correct multipart header and message body boundaries and use the keys' values as parts in the message body, in place of the file content:
curl -u user:pass -k -X POST \
-F key1='<Document>Document 1</Document>' \
-F key2='<Document>Document 2</Document>' \
https://localhost:1234/some/endpoint
However, curl balks that the key values are not real file names:
curl: (26) couldn't open file "<Document>Document 1</Document>"
Is that not a valid way to do it? Is there something wrong with my curl command? I didn't have any success getting curl to execute a multipart POST using -d
either.
Upvotes: 2
Views: 74
Reputation: 11773
POSTing two concatenated XML elements as a single message body (not as multipart) works. However, this is unexpected, since multiple root elements in XML is invalid:
curl -u user:pass -k -X POST \
-H "Content-Type: text/xml" \
-d '<Document>Document 1</Document><Document>Document 2</Document>' \
https://localhost:1234/some/endpoint
Upvotes: 1