Closed mjcollin closed 9 years ago
I hesitate to call this a bug in HTTR, but it certainly is an issue: https://github.com/hadley/httr/issues/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.
At least they're thinking about it again: https://github.com/hadley/httr/issues/187 https://github.com/jeroenooms/jsonlite/issues/73
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.
R treats everything as a vector so when httr JSON encodes list("geopoint"=list("type"="exists")) the result is
This returns a 400 invalid request. The JSON with "exists" works fine.