Я пытаюсь отправить информацию на сервер в течение нескольких дней и запутался ...
попытался решить проблему с urllib3, но получил ошибку. без "json.dumps" я получил ошибку django. без "предметов" не могу получить ответ.
def create_quote(request, order_id='2845', currency='EUR', total_amount='1'):
text = order_id + str(total_amount) + currency
post_data = {
'api_hash': API_HASH,
'hash': hashlib.sha256(text.encode('utf-8')).hexdigest(),
'order_id': order_id,
'currency': currency,
'amount': total_amount,
'items': json.dumps({
'sku': '450',
'name': 'Test Item',
'amount': '1',
'type': 'item_type',
'qty': '10',
'price': '15',
'id': '5619',
'url': 'http://example.com/products/item/example-item-name-5619'
}),
'customer_ip_address': '***',
'url_failure': '',
'url_ok': '',
}
http = urllib3.PoolManager()
url = 'http://checkout.test.pay.g2a.com/index/createQuote'
response = http.request('POST', url, post_data)
return HttpResponse(response.data)
Как правильно отправлять данные json с помощью django / python?