I'm trying to post a request from postman using form data in body section where I upload a csv file and a JSON string, for which i get a response on postman. I would like to replicate the same in locust to do the load testing where I'm not be able to upload the file as I get the error.
Value Error: Data must not be a string.
Below is the code snippet
def project(self):
headers = {'content-type': 'application/json', 'X-ACCESS-TOKEN': 'XXXXXXXXXXXXXXXXX'}
files = [('params_file', ('All_params.csv', open('All_params.csv', 'rb'), 'text/csv'))]
payload = {"df_params":{"geography":"United Arab Emirates","currency":"United Arab Emirates dirham"}}
res = self.client.post("/api/project/setup", headers=headers, data=json.dumps(payload), files=files, catch_response=True)
response = res.content.decode('utf-8')
self.response_api = json.loads(response)
print(self.response_api)
res.raise_for_status()