I am new to anvil and trying to make api POST request with anvil.http.request. I am getting http 400 error.
Here is little snippest from my code, which call the POST request.
@anvil.server.callable
def createShipment(orders_list):
post_url = 'https://apis.tcscourier.com/uat/v1/cod/create-order'
tcs_username = " Test"
tcs_password = "tes"
cost_center = "1123"
headers = {'x-ibm-client-id': "b997ef40-16e3-428a-b1fa-ddf1d0914edf",
'content-type': "application/json",
'accept': "application/json"
}
order_status = None
#tcs_payload = json.dumps(orders_list)
tcs_payload = orders_list
try:
order_status = anvil.http.request(post_url,method="POST",headers=headers,data=tcs_payload)
except anvil.http.HttpError as e:
order_status = "TCS_Error"
print(e)
return order_status
There is nothing wrong either with the api endpoints or POST request payload. The same code works fine in python requests module. I am calling this api from a server module. Can you please tell me what’s I am missing here.