Showing results for 
Search instead for 
Did you mean: 
Pilot Lvl 1
Message 1 of 3

Curl works, but HTTP doesn't

Solved! Go to Solution.

For example,


computer:~ user$ curl -H "Authorization: bearer token" -X POST -d " \

>  { \

>    \"query\": \"query { viewer { login }}\" \

>  } \

> "



However, when I attempt the same query using HTTP



{ "data": null, "errors": [ { "message": "A query attribute must be specified and must be a string." } ] }


2 Replies
Copilot Lvl 3
Message 2 of 3

Re: Curl works, but HTTP doesn't

If you're talking about httpie, use piping:


echo '{"query": "{viewer{login}}"}' | http POST Authorization:"bearer xxxxxxxxxxxxxx"


Pilot Lvl 1
Message 3 of 3

Re: Curl works, but HTTP doesn't

It seems there were a couple issues on my end. For example, one difference was that cURL automatically adds the `User-Agent` which one has to add manually using HTTP. I couldn't figure out the issue with R's http, but after making sure the query were properly escaped with HTTP.jl I got it to work.