Add support for passing list[tuple[str, object]]
to data
#2330
-
I have to make a While this solution works for most cases, it does not work for arrays as the format that the server uses looks like this: I'm happy to put up a PR for this if necessary :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
As far as I know there is no standard way to serialize nested objects in multipart/form-data requests. What you are describing corresponds to what Swagger/OpenAPI calls the "deepObject" serialization method: https://swagger.io/docs/specification/serialization/. The multipart/form-data spec only states that fields may be singular or repeated. You can send a repeated field like: |
Beta Was this translation helpful? Give feedback.
-
I'm just mentioning that this discussion conflates two different things: OP phrasing asked for nesting dictionaries in |
Beta Was this translation helpful? Give feedback.
As far as I know there is no standard way to serialize nested objects in multipart/form-data requests. What you are describing corresponds to what Swagger/OpenAPI calls the "deepObject" serialization method: https://swagger.io/docs/specification/serialization/.
The multipart/form-data spec only states that fields may be singular or repeated. You can send a repeated field like:
httpx.post(..., data={"documents": ["doc1", "doc2"], files=...)
. This will result in "duplicate" data being transmitted. You could also do something likehttpx.post(..., data={"documents": json.dumps( ["doc1", "doc2"]), files=...)
in which case there's no duplicate data but the server has to know that the field is J…