M
M
Maxim2020-08-17 16:00:31
Python
Maxim, 2020-08-17 16:00:31

Why can't I send the file to the server?

I'm trying to send an xml file to the server using the requests library
, I send it like this:

with open("QueryRests.xml","rb") as f:
   r = requests.post('http://localhost:8080/opt/in/QueryRests', files={'QueryRests.xml' : f}, headers={"Content-Type" : "multipart/form-data"})
r.text

I get a server error in response
Error 500 Server Error\n\nHTTP ERROR 500\nProblem accessing /opt/in/QueryRests. Reason:\n Server ErrorCaused by:java.lang.RuntimeException: java.io.IOException: Missing initial multi part boundary

swears at the boundary parameter.
Where to get it? I understand that it points to the end of the file in the package. how to form it?
Is it possible somehow to deceive the server by sending xml not as a file, but simply as text

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-08-17
@maxpointn2point

in the presence of files requests, it sets the desired header itself, and in the key of files it most likely expects the name of the variable, and not the name of the file.
https://requests.readthedocs.io/en/master/user/qui...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question