Example tests and snippets

POSTing JSON data

Sending POST requests is very easy using LoadForge. With JSON data you need to apply a small amount of parsing to it before you post. The below example will submit a simple payload to a URL.

You will see we use json.dumps(payload) to process the payload array, and we set the header Content Type to application/json.

Code example

The below code will post payload to /post/endpoint. You can see the payload is made up of two key value pairs.

import time, json
from locust import HttpUser, task, between

class QuickstartUser(HttpUser):
    wait_time = between(3, 5)

    def api_page(self):
        payload = {
            'key': 'value'
            'question': 'answer123'

        headers = {'content-type': 'application/json'}

        response = self.client.post(

Locust Test Example

LoadForge is powered by locust, meaning open source locust users can copy this script as well. If you are a locust user, consider importing your script to LoadForge to supercharge your testing!

Multi-user login examples