[Python] Problems sending requests to an API

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I've got a problem.... I want to get a correct response from an API of a game I'm playing but it doesn't work properly. I have tested it with Python's requests library, as well as with Postman. With Python it just won't work and I don't understand why. With Postman it worked at the very first time...

    Here is my Python code:

    body = {
    "ids":[
    "831e8094-581c-4ccc-a6a2-62c887dee9a1" # this is my account id or so, but it doesnt matter if u have it, just test it
    ],
    "appBundle":"com.deemedyainc.duels",
    "appVersion":"0.6.6",
    "platform":"Android"
    }

    headers = {
    "Expect": "100-continue",
    "Content-Type": "application/json",
    "X-Unity-Version": "2018.2.14f1",
    "Transfer-Encoding": "chunked",
    "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1.1; SM-G955N Build/NRD90M)",
    "Host": "api-duels-test.galapagosgames.com",
    "Connection": "Keep-Alive",
    "Accept-Encoding": "gzip"
    }
    url = "http://api-duels-test.galapagosgames.com/general/login"
    response = requests.post(url, headers=headers, json=body)


    and the response im getting is 400 Bad Request

    My Postman request:

    Body: [​IMG]

    Header: [​IMG]

    The URI is guaranteed the same. Maybe it has to do with that they're using the websockets protocol instead of the plain HTML protocol? But why would it work with Postman then? I don't think Postman uses the websocket protocol too

    Please, I need your help... :D

    Continue reading...

Compartilhe esta Página