Hello,
I’m working with the SAPI API for P2P but it seems all the post requests are not working for me
Example of the code is shown below
import hmac
import time
import hashlib
import requests
from urllib.parse import urlencode
KEY = "XXXX"
SECRET = "XXXX"
BASE_URL = "https://api.binance.com"
def hashing(query_string):
return hmac.new(
SECRET.encode("utf-8"), query_string.encode("utf-8"), hashlib.sha256
).hexdigest()
def get_timestamp():
return int(time.time() * 1000)
def dispatch_request(http_method):
session = requests.Session()
session.headers.update(
{"Content-Type": "application/json;charset=utf-8", "X-MBX-APIKEY": KEY}
)
return {
"GET": session.get,
"DELETE": session.delete,
"PUT": session.put,
"POST": session.post,
}.get(http_method, "GET")
# used for sending request requires the signature
def send_signed_request(http_method, url_path, payload={}):
query_string = urlencode(payload, True)
if query_string:
query_string = "{}×tamp={}".format(query_string, get_timestamp())
else:
query_string = "timestamp={}".format(get_timestamp())
url = (
BASE_URL + url_path + "?" + query_string + "&signature=" + hashing(query_string)
)
print("{} {}".format(http_method, url))
params = {"url": url, "params": {}}
response = dispatch_request(http_method)(**params)
return response.json()
# used for sending public data request
def send_public_request(url_path, payload={}):
query_string = urlencode(payload, True)
url = BASE_URL + url_path
if query_string:
url = url + "?" + query_string
print("{}".format(url))
response = dispatch_request("GET")(url=url)
return response.json()
params = {
"adsNo": "11405603645832523776"}
response = send_signed_request("POST", "/sapi/v1/c2c/ads/getDetailByNo", params)
print(response)```
It's returning this error
{'code': 500000001, 'msg': 'You have entered incomplete information. Please update the data.'}
The code produces this URL
POST https://api.binance.com/sapi/v1/c2c/ads/getDetailByNo?adsNo=11405603645832523776×tamp=1663844115506&signature=0c6214731405ea1f08b6b1236a085675e3cb004948a637a483d1f22311be3452
Which is similar to the URL in the docs, no data is missing as the error is suggesting
What can i do to solve this error?