A Simple Post Request Always Returns "Invalid Request"

This is a very simple post request but I get no data.

This my code:

import requests

url = '
form_data = {'appid': '730', 'sort': 'price', 'name':'sticker'}

r = requests.post(url, data = form_data)

response = r.text

The response is:

'{"success":false,"error":"Invalid request","response":[]}'

How can I get some valid response?

2

1 Answer

Try this:

import json

import requests

headers = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/111.0",
    "X-Requested-With": "XMLHttpRequest",
}

form_data = {
    "sort": "price",
    "sort_desc": 1,
}

r = requests.post(
    "",
    headers=headers,
    data=form_data,
)
print(json.dumps(r.json(), indent=4))

Output:

{
    "success": true,
    "response": {
        "totalResults": 192723,
        "page": 0,
        "perPage": 500,
        "results": {
            "730": [
                {
                    "a": 49,
                    "c": "Sticker | Titan (Holo) | Katowice 2014",
                    "g": 380155439,
                    "h": 188530139,
                    "x": 0,
                    "i": 100000,
                    "k": "8847ff",
                    "q": "MTA3OTEw",
                    "o": "Sticker",
                    "t": 27099487,
                    "v": [
                        {
                            "f": "28274420298",
                            "u": 1
                        }
                    ],
                    "b1": "9828591403546145955",
                    "order": 0,
                    "e": 6
                },
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest