How can i create a post request like this with python requests?
$url = 'https://joinposter.com/api/incomingOrders.createIncomingOrder'
. '?token=687409:4164553abf6a031302898da7800b59fb';
$incoming_order = [
'spot_id' => 1,
'phone' => '+380680000000',
'products' => [
[
'product_id' => 169,
'count' => 1
],
],
];
$data = sendRequest($url, 'post', $incoming_order);
I've tried to do it like this:
payload = {'token': 687409:4164553abf6a031302898da7800b59fb,
'spot_id': 1, 'phone': '+380680000000', 'products': {'product_id': 169, 'count': 1}}
r = requests.post('https://joinposter.com/api/incomingOrders.createIncomingOrder', params=payload)
But it didn't work. Parameter 'products' is not created right. This is how the created URL looks like:
https://joinposter.com/api/incomingOrders.createIncomingOrder?token=704698%3A8544082b36a413a51b5c8c3ce0e2b162&spot_id=1&phone=%2B380680000000&products=product_id&products=count
So how can i create a post request with arrays of arrays in it?
json.dumps(...)which converts the dictionary into a text format. It is then up to the server to convert it back.