Reqwest: Nested elements in form trigger error

Created on 27 Mar 2018  路  2Comments  路  Source: seanmonstar/reqwest

When calling request.form(data) with a form body that looks roughly like this:

// {"nested": {"yes": "y"}, "user": "foo", "password": "fizz"}
Some(Form(Object({"nested": Object({"yes": String("y")}), "password": String("fizz"), "user": String("foo")}))) }

I'm getting the following error:

Error(Reqwest(Error { kind: UrlEncoded(Custom("unsupported value")), url: None }), State { next_error: None, backtrace: None })

I would expect reqwest to send the following request body:

nested[yes]=y&password=fizz&user=foo

Most helpful comment

I ran across this same limitation when trying to use .query(data) with a Vec of values assigned to a key. I raised an issue on the serde_urlencoded project and was told it was out of scope for the project and referred to serde_qs. serde_qs appears to support the cases that @kpcyrd and I were attempting to use.

I propose that we investigate switching to using serde_qs in reqwest if possible. In the meantime, it could be useful to document this limitation and potential workarounds (eg. is it possible to pre-serialize using serde_qs and pass it to .query or .form as a string without issue?).

All 2 comments

I ran across this same limitation when trying to use .query(data) with a Vec of values assigned to a key. I raised an issue on the serde_urlencoded project and was told it was out of scope for the project and referred to serde_qs. serde_qs appears to support the cases that @kpcyrd and I were attempting to use.

I propose that we investigate switching to using serde_qs in reqwest if possible. In the meantime, it could be useful to document this limitation and potential workarounds (eg. is it possible to pre-serialize using serde_qs and pass it to .query or .form as a string without issue?).

Hi, I am getting this issue on my project
Err(Error(UrlEncoded(Custom("unsupported value"))))
I am using an vector assigned to 1 of my keys.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CGQAQ picture CGQAQ  路  4Comments

yazaddaruvala picture yazaddaruvala  路  5Comments

kpcyrd picture kpcyrd  路  4Comments

richardanaya picture richardanaya  路  5Comments

theduke picture theduke  路  6Comments