I am passing a JSON paylaod in a request in a python FAST API. Interesting this code is running fine on my computer but throws error when deploying in Azure container. I don't expect that to be an issue but something wired is going on.
payload = await request.json()logger.info("Executing %s", json.dumps(payload))end_point = "/Register"end_point = end_point + get_register_query_string(payload) //getting error in this functiondef get_register_query_string(payload) -> str:"""Creates get der register query string"""query_string = "?ID=" + payload["id"][0:10]return query_string
here is the output
Executing "{\r\n \"id\": \"31206796930\",\r\n \"companyCode\": \"ET\"\r\n}"ERROR - string indices must be integersquery_string = "?ID=" + payload["id"][0:10]
adding following line in get_register_query_string makes it working but I am trying to understand the reason
payload = json.loads(payload)