httpx.post get a typing error when data is plain string #2849
-
|
Usually http post method sends data in JSON format, and the I used Yes, that is quite rare, and I suppose such APIs are badly designed. However, since I get a typing error saying str is incompatible with RequestData when I write such codes: import httpx
def example function(url:str, data_str:str):
return httpx.post(url, data=data_str, header = {"Content-Type":"text/plain"})Anyway, it works properly when I disable typing check. However, I wish the typing could be reconsidered. I simply changed the line |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hi! I think the content argument is what you are searching for. You can do something like this httpx.post(url, content="my plain text", header = {"Content-Type":"text/plain"}) |
Beta Was this translation helpful? Give feedback.
Hi! I think the content argument is what you are searching for.
You can do something like this