1

The title might not make sense but my problem is that I have set something as the body in the request but when I print it out it doesn't print what the actual body was.

Here is my code:

data = {
    "offers": [
        {
            "userId": 435771547,
            "userAssetIds": [
                2409285794
            ],
            "robux": 0
        },
        {
            "userId": userId,
            "userAssetIds": [
                1380767576
            ],
            "robux": 0
        }
    ]
}

requested = requests.post("https://trades.roblox.com/v1/trades/send", data = data, cookies = cookie, headers = {
    "Content-Type": "application/json",
    "X-CSRF-TOKEN": token
})

print(requested.request.body)
Trym
  • 15
  • 6

1 Answers1

0

Requests returns a response from requests.post(), and not a request itself. So usually you will write something like respone = requests.post(...) and say check response.status_code, then read response.json(), etc.

To see the request itself say for the debugging purpose you could use a more low-level approach with the use of a requests.Request() to construct the request and then print it. You can find a good example in this answer.

Another option is to analyze the request is logging. See an example here.

By the way if you want to send a json body, use json keyword argument instead of data.

requests.post('https://httpbin.org/post',
              json={'a': 'hello', 'b': [1, 2, 3]})
Eugene Naydenov
  • 7,165
  • 2
  • 25
  • 43