Issue
I am trying to following CURL command in mac terminal:
curl --X POST \
--url http://localhost:3000/api \
--header 'accept: application/json' \
--header 'accept-encoding: gzip, deflate, br' \
--header 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
--header 'authorization: Bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'connection: keep-alive' \
--header 'content-type: multipart/form-data' \
--header 'origin: http://localhost:3000' \
--header 'postman-token: 6994926d-2406-b65e-d7e2-6a3622588c09' \
--header 'referer: http://localhost:3000/' \
--header 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' \
--data '{"query":"mutation{\n sendMessage(input:{toUserId:\"4789838293237760\",message:\"Hello, Are you there?\"})\n {\n id\n message\n modifiedOn\n linkedUsers\n {\n id\n role\n firstName\n lastName \n }\n \n }\n}","variables":null}' \
-F file=@/Volumes/Drive \
B/dev/zapi/uploads/IMG-20180207-WA0020.jpg
Why am I getting the following error:
You can only select one HTTP request method! You asked for both POST
Please help me.
Thanks in advance.
Solution
The problem with the CURL request command is you are using both --data
(Post Data) and -F
(Multiform Data).
Thats is why it is giving error.
Here is the answer:
curl --X POST \
--url http://localhost:3000/api \
--header 'accept: application/json' \
--header 'accept-encoding: gzip, deflate, br' \
--header 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
--header 'authorization: Bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'connection: keep-alive' \
--header 'content-type: multipart/form-data' \
--header 'origin: http://localhost:3000' \
--header 'postman-token: 6994926d-2406-b65e-d7e2-6a3622588c09' \
--header 'referer: http://localhost:3000/' \
--header 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' \
-F file=@/Volumes/Drive\ B/dev/zapi/uploads/IMG-20180207-WA0020.jpg \
-F "query=mutation{\n sendMessage(input:{toUserId:\"4789838293237760\",message:\"Hello, Are you there?\"})\n {\n id\n message\n modifiedOn\n linkedUsers\n {\n id\n role\n firstName\n lastName \n }\n \n }\n}" \
-F "variables=null"
Hope it helps.
Thanks
Answered By - user9779612 Answer Checked By - Marie Seifert (WPSolving Admin)