Skip to content
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

Query field exists/absent doesn't accept lists from R #2

Closed
mjcollin opened this issue Mar 5, 2015 · 3 comments
Closed

Query field exists/absent doesn't accept lists from R #2

mjcollin opened this issue Mar 5, 2015 · 3 comments
Labels

Comments

@mjcollin
Copy link

mjcollin commented Mar 5, 2015

R treats everything as a vector so when httr JSON encodes list("geopoint"=list("type"="exists")) the result is

{
  "geopoint": {
    "type": ["exists"]
  }
}

This returns a 400 invalid request. The JSON with "exists" works fine.

@godfoder
Copy link
Collaborator

godfoder commented Mar 5, 2015

I hesitate to call this a bug in HTTR, but it certainly is an issue:
r-lib/httr#159

That has some workarounds to use a different JSON,

It also seems like:

httr::POST('https://api.hipchat.com/v2/rooms/room_id/notification?auth_token=token',
  body = jsonlite::toJSON(list(message = 'hello hipchat'),auto_unbox=TRUE), 
  httr::content_type_json())

Would work without switching encoders to rjson. It doesn't seem like anyone is interested in fixing this, but "I refuse to treat single item lists the same as literals, because my language chooses to treat literals as single item lists" doesn't seem like an argument that holds much water.

Since workarounds exist, I'm going to wontfix this.

@godfoder godfoder closed this as completed Mar 5, 2015
@godfoder
Copy link
Collaborator

godfoder commented Mar 6, 2015

At least they're thinking about it again:
r-lib/httr#187
jeroen/jsonlite#73

@jeroen
Copy link

jeroen commented Mar 6, 2015

You're welcome to joint he discussion and argue about which defaults you would like to see, or how we can make it easier to set toJSON parameters in httr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants