Manually send POST request to fire callback

I am trying to manually send a POST request to activate a callback by copying the payload from inspecting the application page. Is this possible?

The purpose is I am trying to perform load testing using Locust and I want to click a button in the app. I can send a GET request to the button’s .js but then to POST the chart I want to send a POST to _dash-update-component and I get 500 error.

What is the proper way to do this?

Here’s what my looks like (I removed data for testing purposes)…

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

class QuickstartUser(HttpUser):
    wait_time = between(1, 2.5)

    def hello_world(self):
        payload = {
                        {"test": 10}
                        {"name":"Jul 2021","id":"Jul 2021"},
                        {"name":"Aug 2021","id":"Aug 2021"},
                        {"name":"Sep 2021","id":"Sep 2021"},
                        {"name":"Oct 2021","id":"Oct 2021"},
                        {"name":"Nov 2021","id":"Nov 2021"},
                        {"name":"Dec 2021","id":"Dec 2021"},
                        {"name":"Jan 2022","id":"Jan 2022"},
                        {"name":"Feb 2022","id":"Feb 2022"},
                        {"name":"Mar 2022","id":"Mar 2022"},
                        {"name":"Apr 2022","id":"Apr 2022"},
                        {"name":"May 2022","id":"May 2022"}

Did you ever figure this out @conv3d ? I’m trying to use Locust with a dash application aswell myself and stuck on this

Hello @dhruvyy,

Welcome to the community!

You can send a post request by using a clientside callback and performing the fetch in it. You can either return something from the fetch or return window.dash_clientside.no_update after the function is done.

To manually trigger a callback from JS, you can use something like my get_setProps function to set the property of the component to trigger the callback.

Or you can check out my page caching which preloads pages to a cache by creating the post request and capturing the response.

Thanks for the response @jinnyzor.

I don’t have the choice of changing the code to change callbacks to client side callbacks.

Is there no way to actually send a simple post request to do load testing with locust?

Also, would you have an example you can point me to about page caching?

Sure, here is the post about caching:

I’m attempting to send a POST request to the _dash-update-component endpoint to activate a callback responsible for updating a chart. However, the server consistently responds with a 500 error. I’ve ensured that the payload from inspecting the application page is accurate, but I suspect there might be additional considerations or specific headers required for this interaction.

Hello @ThomasElias,

Welcome to the community!

This is not the case, I use it all the time for preloading page caches. :grin:

Can you please provide a test app where you are trying to achieve this?