-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post with JSON data #157
Comments
client is mostly just a requests object Extended post use (including mentioning data, which is what you want for JSON as dict): Requests documentation showing post of json examples: |
was getting HTTP415 until i read that last link
specifying content type may be optional, if you don't care about the response. |
Shorter solution is payload = {"some": "payload"}
r = l.client.post("/post/endpoint", json=payload) This will encode JSON and set headers for you. |
doesn't work. only HTTP 500 errors show up. |
@cyberw When post with json and add headers, always 500.... |
rather than using json.dumps, we can try to pass string as data parameter MY_JSON = """
{
"intent": {
"id": "123",
"name": "456"
}
}
"""
class LoadTesting(HttpUser):
@task
def parse_last_notice(self):
self.client.post("/somewhere", data=MY_JSON ) |
Can someone point me in the right direction on how to leverage locust to make a Post to an API endpoint that is expecting JSON data?
The text was updated successfully, but these errors were encountered: