binance / binance-pay-connector-python

A lightweight library that works as a connector to Binance pay public API
17 stars 9 forks source link

API returning Request body is not a valid json object. #6

Open LuizDMM opened 1 year ago

LuizDMM commented 1 year ago

Hey guys, how are you doing today?

I'm using this library in a work project, but when I make the request, I'm getting as response: {"status":"FAIL","code":"400008","errorMessage":"Request body is not a valid json object."} I'm following your documentation, and this is the code I'm using to make the request:

    parameters = {
        "env": {
            "terminalType": terminal_type,
        },
        "merchantTradeNo": order_id,
        "orderAmount": order_amount,
        "currency": currency,
        "goods": items_list,
        "buyer": {
            "buyerName": {"firstName": first_name, "lastName": last_name},
            "buyerEmail": email,
        },
        # "webhookUrl": settings.BINANCE_PAY_WEBHOOK_URL,
    }
    if client_ip is not None:
        parameters["env"]["orderClientIp"] = client_ip
    if middle_name is not None:
        parameters["buyer"]["buyerName"]["middleName"] = middle_name
    print("Parameters: {}".format(parameters))
    return client.new_order(parameters)

I looked at your source code and the request body seems to be correctly formatted as json, so what is happening? Can someone help me with this?