Post request is successful on reqbin but not in Python script

Viewed 75

I am making a post request and it has been done successfully on reqbin but when I use the code in my script, even if I copy and paste exactly, it doesn't work. I'm getting a 500 status on these and if I try other languages i get a 301. But I don't know what exactly is going on or what I'm missing.

expected response:

```{
    "data": {
        "txGasUnits": 132500,
        "returnMessage": "",
        "smartContractResults": null
    },
    "error": "",
    "code": "successful"
}```

response from python:

b'{"data":null,"error":"transaction not found","code":"internal_issue"}

response from php and bash:

```<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.14.0 (Ubuntu)</center>
</body>
</html>```

the code provided for Python:

import requests
from requests.structures import CaseInsensitiveDict

url = "http://testnet-gateway.elrond.com/transaction/cost"

headers = CaseInsensitiveDict()
headers["Authorization"] = "Bearer mt0dgHmLJMVQhvjpNXDyA83vA_PxH23Y"
headers["Content-Type"] = "application/json"

data = """
{"value": "0",
 "sender": "erd1qgjj3t38fgv0pscvr3xk0xq2gkm974mx0wz8afnqfewkevpn7v8s70np82",
 "receiver": "erd14edl4fvr8wc2sczrz5af6tfmfucgqzsh4u73hnxw96l07cekdg6schwtsh",
 "data": "RVNEVFRyYW5zZmVyQDUyNDk0MzQ1MmQ2MjM0MzA2MjMyNjJAMDRlNzNlZjNjNjdlMTUwMDAwCg==",
 "chainID": "T",
 "version": 1}
"""


resp = requests.post(url, headers=headers, data=data)

print(resp.status_code)

I added the php and bash just to show that other code snippets also failed, and in a different way, incase that may be relevent. I tried my own code and had the same result. Then when I used reqbin i got it to succeed, and then after struggling with it a bit I simply copied the code they generated and tried that precisely but it still didn't work. What could be the error?

0 Answers
Related