Comments (11)
I'd think you'd want:
meta <- toJSON(list("title"=title, "description"=description, "type"=type))
POST(request, config=session, body=meta, add_headers("Content-Type" = "application/json"))
from httr.
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?
from httr.
The put request, you mean? Just add the verbose()
config:
with_config(verbose(), figshare_create(...)
from httr.
hmm, I get this
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 401 Unauthorized
< Server: nginx/0.8.54
< Date: Thu, 30 Aug 2012 16:32:53 GMT
< Content-Type: application/json; charset=UTF-8
< Connection: keep-alive
< Content-Length: 72
<
* Connection #0 to host api.figshare.com left intact
Response [http://api.figshare.com/v1/my_data/articles]
Status: 401
{"error": "Incorect content_type. Expected application/json, received:"}
>
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
from httr.
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.
from httr.
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)
from httr.
Hmmm, that looks equivalent to your R code. Can you email me the full output?
from httr.
The problem is this line in make_request
:
config <- c(config, signed$config)
because c.config
doesn't have any logic for combining headers.
from httr.
Nice work, thanks. Staying tuned for the update and thanks again for all the help.
from httr.
Any thoughts on concatenating headers?
from httr.
Fantastic! you rock.
from httr.
Related Issues (20)
- more docs on creating a complex request body HOT 1
- Add mime type qs::qread() to httr::content() HOT 1
- lexical error: invalid char in json text. HOT 1
- GET request with an empty header HOT 1
- Vectorise functions HOT 1
- Can't get content for FTP directory listing HOT 4
- OAuth callback url is encoded while it shouldn't.
- R CMD check failure on musl-based systems HOT 1
- Release httr 1.4.5
- is.character(headers) is not TRUE HOT 1
- httr & use_proxy vs RCurl behaviour difference HOT 1
- Forbidden with httr, but works with py requests HOT 7
- Release httr 1.4.6
- Make file upload seekable
- Release httr 1.4.7
- Use httpbin mirror
- modify_url() cannot handle API versioning HOT 1
- httr 1.4.7: Option seekfunction (20167) has unknown or unsupported type HOT 4
- Upkeep for httr (2023)
- Bug: Executing `http::GET()` in parallel results in an error when no single core GET request was issued before. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httr.