Sofien
Sofien

Reputation: 478

Problems sending requests to an API

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: Body

Header: Headers

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 guys, I need your help... :D thanks :)

Upvotes: 2

Views: 236

Answers (1)

Sofien
Sofien

Reputation: 478

A little bit late, but I wanted to add the solution because t.m.adam just wrote it as a comment: As t.m.adam wrote: the solution was to remove the "Transfer-Encoding" header key.

Upvotes: 0

Related Questions