使用curl rest api发送,具有多个内容类型的多部分数据

I used wiztools and set 3 parameters to rest api.

  • appkey content-type text
  • appsecret content-type text
  • data content-type application/json

How can i define seperate content-types? You can look this wiztools request picture to understand best. http://i.stack.imgur.com/JDVKG.jpg

When i use curl, response is ; The current request is not a multipart request

How can i create a request like wiztool's "multipart body" request with curl?

A new question; What is multipart mode in wiztool? If i set it to rfc6532 or strict, answer is true but if i set it "browser compatible" answer is "data not defined."

Now i am getting "data not defined" in curl result. How can i set this multipart mode to strict or rfc6532 in curl ?

You will need to set the content-type header to

Content-type: multipart/form-data, boundary=AaB03x

The boundary value can be pretty much any value as long as it is unique.

Then you need to build a request body that looks like this...

--AaB03x
content-disposition: form-data; name="appkey"
Content-Type: text/plain; charset=UTF-8

{put key here}
--AaB03x
content-disposition: form-data; name="appsecret"
Content-Type: text/plain; charset=UTF-8

{put secret here}    
--AaB03x
content-disposition: form-data; name="data"
Content-Type: application/json; charset=UTF-8

{put json body here}

If you have trouble getting the body format correct, just use the Wiztool and send it via a Runscope URL and that will allow you to see exactly the body and header values that Wiztool is sending to the API.