Closed TheRealStingo closed 1 month ago
I think you should send them just like normal json files……
from curl_cffi import CurlMime, requests
mp = CurlMime()
mp = CurlMime.from_list(
[
{
"name": "bookerChoicesJson",
"content_type": "application/json",
"filename": "whatever.json",
"data": '{"insurance":{}}',
},
]
)
r = requests.post("https://httpbin.org/post", multipart=mp)
Does this work for you?
Not working.
Description: I am currently working with the curl_cffi library and need to send JSON data as part of a multipart request. Specifically, I am looking for guidance on how to correctly send JSON data in a multipart form without using files.
Here is an example of the multipart form data I need to send:
However, I have not been able to find clear documentation or examples on how to achieve this using the curl_cffi library. My goal is to send the JSON data ({"insurance":{}}) in the field bookerChoicesJson as a part of the multipart form.
Questions: How can I send JSON data like the example above using curl_cffi in a multipart request? Is there a way to manually specify boundaries or should I rely on curl_cffi to generate boundaries automatically? Are there any best practices for handling multipart requests with JSON data in this library?