Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17447

Error Getting JSON Attribute from a JSON Payload Deployed in an Azure Container

$
0
0

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)


Viewing all articles
Browse latest Browse all 17447

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>