P
P
Python Newbie2021-09-20 07:26:27
Python
Python Newbie, 2021-09-20 07:26:27

Why Json validation error List when working with kiwi api?

I have code:

post_args = {
        "id": str(int(time.time() * 1000)),
        "sum": {
            "amount": float(balance),
            "currency": 643
        },
        "paymentMethod": {
            "type": 'Account',
            "accountId": '643'
        },
        "fields": {
            "account": message.text
        }
    }
post_args['comment'] = 'Вывод денег'
s = requests.Session()
response = s.post(
        url='https://edge.qiwi.com/sinap/api/v2/terms/99/payments',
        json=post_args
    )

data = response.json()

with open('data.json', 'w', encoding='utf-8') as f:
    json.dump(data, f, ensure_ascii=False, indent=4)


An error is written to the data.json file:
{
    "message": "Json validation error List((obj.sum.currency,List(JsonValidationError(List(error.expected.jsstring),WrappedArray()))))"
}


What did I screw up?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-09-20
@Levman5

sum.currency should be the string
https://developer.qiwi.com/en/qiwi-wallet-personal...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question