Getting Price of an avatar asset in Python

  1. What do you want to achieve? Getting Price of an avatar asset in Python.

  2. What is the issue? When using requests.session().post() with the headers and payload from the https://catalog.roblox.com/docs#!/Catalog/post_v1_catalog_items_details Documentation im getting stuck at the Token Validation Failed Response.

  3. What solutions have you tried so far? I tried to get the cookies from https://www.roblox.com/ and use them on the API POST request but still got the same error.

My tried Code:

import requests

Session = requests.session()

headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}

data = '{ \\ "items": [ \\ { \\ "itemType": "Asset", \\ "id": 6781218036 \\ } \\ ] \\ }'

response = Session.post('https://catalog.roblox.com/v1/catalog/items/details', headers=headers, data=data)

print(response.text)

As the error message states, you likely need a token in the headers of this request. Likely, your x-csrf token.

When using requests.session() Roblox will set you automaticlly the headers, include the X-CSRF-TOKEN but cookies not.

You don’t seem to have a ROBLOSECURITY in your cookies?

Check if you are getting “Token Validation Failed.” and if you are getting it, just add a header parameter to your session as:

session.headers["X-CSRF-TOKEN"] = request.headers["X-CSRF-TOKEN"]

So have I to specify the cookie or the token? Your code snippet makes no sense.