-
|
I tried to implement the code sample for Code: The I use curl: Expected Behaviour Actual Behaviour Version: 1.17.1 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Looks like the issue is not express specific: I have the same problem for |
Beta Was this translation helpful? Give feedback.
-
|
Weirdly, things work with |
Beta Was this translation helpful? Give feedback.
-
|
If you append the flag $ curl http://localhost:4000/graphql2 --data-urlencode "query=query Q { hello }" -i
HTTP/1.1 415 Unsupported Media Type
X-Powered-By: Express
Date: Mon, 10 Apr 2023 07:49:22 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunkedThis is because POST with To have curl encode the data to the URL, you have to add the $ curl http://localhost:4000/graphql2 --data-urlencode "query=query Q { hello }" -G
{"data":{"hello":"hello"}} |
Beta Was this translation helpful? Give feedback.
If you append the flag
-ito the curl request to check the headers you'll get:$ curl http://localhost:4000/graphql2 --data-urlencode "query=query Q { hello }" -i HTTP/1.1 415 Unsupported Media Type X-Powered-By: Express Date: Mon, 10 Apr 2023 07:49:22 GMT Connection: keep-alive Keep-Alive: timeout=5 Transfer-Encoding: chunkedThis is because POST with
application/x-www-form-urlencodedbody is not supported. Only with GET.To have curl encode the data to the URL, you have to add the
-Gflag.