I am using Locust to try and perform a load test. I can't get a good (200) response from the API we are using. It continually gives me a:
{
"message": "Invalid API key",
"status": 400
}
However, using the same information I am using for Locust in Postman generates a proper response. The post is a cross site post so it's not going to the host defined for locust. I have replaced any sensitive info with Redacted. So what am I doing wrong? Any help appreciated.
Code Example:
targetURL = 'https://Redacted, name=https:Redacted'
searchBody1 = {"params": "facets=%5B%22Property%20Type%22%2C%22amenities.Property%20Amenities%22%2C%22amenities.Suitability%22%2C%22amenities.Area%20Activities%22%2C%22Bedrooms%22%2C%22Total%20Beds%22%2C%22Bathrooms%22%5D&hitsPerPage=0"}
searchHeader1 = {'Host': 'Redacted',
'Connection': 'keep-alive',
'Content-Length': '223',
'accept': 'application/json',
'Origin': 'Redacted',
'User-Agent': 'Mozilla/5.0 (Linux; Android 8.0.0; SM-G930U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36',
'content-type': 'application/x-www-form-urlencoded',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-Mode': 'cors',
'Referer': 'Redacted',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9'}
response = self.client.post(url=targetURL, json=searchBody1, headers=searchHeader1, catch_response=True)