Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
How to pass form data body in Onshape API endpoint using python?
Hi! I am trying to use this endpoint in python, but every time I get the 400 status code. I suspect the problem is that I am sending the request body incorrectly. I tried quite a few options on how I could send the file, then I got to the simplest option and still failed.
The simplest option I am talking about: files = {'file': ('text.txt', 'some,data,to,send\nanother,row,to,send\n')}
The headers also are ok: Accept': "application/json", 'Content-Type': "multipart/form-data"
The request itself is following: res = requests.request((
method
='POST', parsed_url.geturl(),
headers
=headers,
files
=files,
allow_redirects
=False,
stream
=True)
I guess it's worth mentioning that my configuration works fine for a large number of requests from the Onshape API list, but this is the only one that caused this dead end. If necessary, I am ready to provide much more information, but I focused on the body of the request, since I assume that is where the problem lies.
Thanks in advance for your help!