1

This is what I observed with f12 in chrome: chrome output

The payload here doesn't seem like json data since there is 89:42 in the front.

payload = ["auth",{"form":{"id":"xxxx","email":"xxx@xxx"}}]
resp = requests.post(url, json=payload, headers=headers)
print(resp.status_code)

payload = '89:42["auth",{"form":{"id":"xxxx","email":"xxx@xxx"}}]'
resp = requests.post(url, data=payload, headers=headers)
print(resp.status_code)

The status code of the above resp are both 400(bad request). How can I post it correctly?

[EDIT] I actually used Session to maintain the session. I'v also tried to change the content-type to application/json. But it didn't work. And as your can see in the picture, the default content-type seen with f12 is text/plain.

[EDIT] Some said the data or json argument must be a dict. Does it means that I should rewrite 89:42["auth",{"form":{"id":"xxxx","email":"xxx@xxx"}}] to change its type to dict? How should I do this?

Altair
  • 11
  • 2

1 Answers1

1

From reading the requests documentation, you need to pass your payload as a dictoinary like this:

response = requests.post('https://httpbin.org/post', data = {'key':'value'})
Anatol
  • 3,720
  • 2
  • 20
  • 40
  • I don't think it would success by passing them like this.The format of post is not `form-data`. – jizhihaoSAMA Jul 20 '20 at 12:50
  • @jizhihaoSAMA if you want to send `multipart/form-data` encoded data, check this answer: https://stackoverflow.com/a/12385661/11804213 – Anatol Jul 20 '20 at 13:29
  • The Request Payload is `89:42["auth",{"form":{"id":"xxxx","email":"xxx@xxx"}}]`. How can I change it into a `dict`? – Altair Jul 21 '20 at 02:43