When sending a post it returns error 400 bad request for url

Hi @RobotK

You need to get the raw request from the consol in postman (see below)

It wasn’t obvious to me at first how to do this, so here’s what I did:

Now you can see what was really sent by postman, this is what you need to reproduce with requests.

form data body can look like:

----------------------------postman
Content-Disposition: form-data; name="data"
2.2.2.aaa.111
----------------------------postman
Content-Disposition: form-data; name="name"
test
----------------------------postman--

it can also look like:

data=2.2.2.aaa.111&name=test

where JSON body’s look like:

{"data":"2.2.2.aaa.111","name":"test"}

Once you really know what postman is sending and what your app server is expecting you can then know what you need to recreate.

Here is an example of a form-data post body from one of my request library scripts:


as you can see the request headers (orange box) is separate from the the request body (green box) so having the body in the headers json that you showed doesn’t look right.

This line:

 Content-Type: :multipart/form-data: boundary=--------0348…

Indicates that it’s probably the first form data body type I mentioned, if so you’ll need to construct the boundary string first, add it into your headers and then construct the body with it, then put it all together in the post. If my suspicions is correct you’ll need a completely different approach to constructing the request body.

Hopefully this gets you on the right track, let me know if you need help constructing the form data body with the boundary strings,

Dave.