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
Specifying content type in PUT requests? #19
Comments
I'd think you'd want:
|
Ah, good idea. Unfortunately I'm getting the exact same error with this. Is there a way to see the literal POST request for debug purposes? |
The put request, you mean? Just add the with_config(verbose(), figshare_create(...) |
hmm, I get this
Looks to me that it's actually the authentication that failed? ("401 Unauthorized"). The same keys work fine when I try the ruby client not sure where I have gone wrong. Thanks for the advice |
Is that the whole output? That's only what the server is sending back to you, not what you're sending to the server. Otherwise, can you find the source code for that ruby method? It'll help to understand exactly what it's sending. |
I left out the top of the output that has the keys, can email that to you. Here's the entire ruby command (keys scubbed) which works fine require 'oauth'
require 'json'
key = "qMXXXXXXXXXXXXXXX"
secret = "zQXXXXXXXXXXXXXX"
token = "SrXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
secret_token = "yqIXXXXXXXXXX"
consumer = OAuth::Consumer.new(key, secret, {:site=>"http://api.figshare.com"})
token = { :oauth_token => token,
:oauth_token_secret => secret_token
}
client = OAuth::AccessToken.from_hash(consumer, token)
body = JSON.generate('title'=>'Test dataset', 'description'=>'Test description', 'defined_type'=>'dataset')
result = client.post('/v1/my_data/articles', body, {"Content-Type"=>"application/json"})
print result.body (from here: http://api.figshare.com/docs/demo_ruby.html#sample-code-for-ruby) |
Hmmm, that looks equivalent to your R code. Can you email me the full output? |
The problem is this line in
because |
Nice work, thanks. Staying tuned for the update and thanks again for all the help. |
Any thoughts on concatenating headers? |
Fantastic! you rock. |
I'm probably doing something wrong here, but it's not clear how I specify content requests in PUT.
I'm trying to access the Figshare API with httr.
Authentication with httr and oauth 1 seems to work fine:
And most of the basic GET commands work. But I try to a post method and get:
and get the error
The GET -based methods work fine (those calls also require the 'session' variable, but I guess this could still be an authentication issue since they shouldn't actually need to authenticate since those should be public methods)?
Any ideas? (I'm building out API in rfigshare package here: https://github.com/ropensci/rfigshare)
The text was updated successfully, but these errors were encountered: