Skip to content
Advertisement

Formatting Json for Python LocustIO

Why am I getting bad request for this post calls? It has to do with json formatting. How do I reformat the json object passed as param? I’m running a load test using LocustIO and Python.

JavaScript

Advertisement

Answer

json.dumps takes as input json object (lists & dictionaries) and serializes it giving a string as output. You are feeding it with nameInquiry, which is already a string by itself, thus the error.

Furthermore post gets a dictionary as input, so there is no need to serialize it. The simple solution is to set nameInquiry as a json object (notice the missing """ below) and feed it directly to post.

JavaScript

Otherwise you can keep the string and deserialize it using json.loads:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement