New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST always has content_type 'application/x-www-form-urlencoded'? #104
Comments
This seems to work for me:
In the Sinatra app:
Result:
|
@Cerales - try adding a #to_json to your payload |
I have the same issue, rest-client is broken so time to turn to something else I guess. Sucks because the API is nice but I need to be able to post json and it won't let me. RestClient.post "https://#{uid}:#{pwd}@api.twilio.com/#{uri}", { "to" => to, "from" => from, "body" => "Hey ho let's go" }.to_json, { content_type: 'application/json' } that request tells me the content-type is wrong and that I should specificy 'application/x-www-form-urlencoded' instead so obviously this needs to be fixed. |
It's working fine for me. Can't duplicate. |
Sorry, I wasn't able to reproduce this on master. Are you still seeing this? Could you provide a test case? |
The problem seems to be that if the payload is being passed in as a hash, then the content-type is overridden. Unless you want to pass a header overridden message back to the user due to the payload structure, I think you can close this issue. @quigebo is right on. |
Yeah, it seems possible that rest-client should raise an exception if you pass a |
Would be nice if this was at least in the examples. One wouldn't expect to have to convert a hash to a json string when all the other examples show the payload being a hash. Also, one would expect to be able to "override" the content type (and other headers) and not be overridden without the user knowing about it. |
+1 |
Why not derive the encoding of the hash from the content_type specified? |
Using a GET request we must not send the payload, otherwise RestClient will complain because isn't allowed to use content type as JSON and payload as a Hash. See rest-client/rest-client#104
Using a GET request we must not send the payload, otherwise RestClient will complain because isn't allowed to use content type as JSON and payload as a Hash. See rest-client/rest-client#104
Using a raw hash instead of JSON payload was causing a header override warning in rest-client. See rest-client/rest-client#104 for details; because an empty hash is passed directly as the payload, rest-client complains about incompatible headers. Solution is to simply json encode the empty hash.
+1 |
I'm using Rest-Client to submit a simple POST to CouchDB, with content-type application/json. Rest-Client's UrlEncoded class has this code, though:
Is there a way around this? I don't see why the content type should be messed with if the developer has specified it.
I'm calling it like this:
Here are the parameters:
Payload is a string, but I've tried it with a hash too.
The text was updated successfully, but these errors were encountered: