How to pass custom post data to jobs request along with StartCommand?

I am currently using a web service to process requests one at a time. However I’d like to use jobs so I can queue them since its possible more than one can be requested at the same time. I understand how to create jobs but I fail to understand how to create a job and pass along custom POST data to run the script.

As far as I can tell, when creating a job the only variable I can pass is the startCommand? How do I pass additional data?

For reference, this is the data I need to pass to each job request. My current web service request looks similar to this using PHP and Guzzle:

             $response = $client->request('POST','.....onrender.com',[
                'json' => [
                            //Pass credentials
                                'user' => $usr,
                                'pass' => $pswd,
                                'webparm'  => $webparm
                                'userid'   => $userid
                ],
               
            ]);

The following is an example does not work when attempting to test this:

curl --request POST 'https://api.render.com/v1/services/crn-1111/jobs' \
    --header 'Authorization: Bearer API_TOKEN' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "startCommand": "echo hi",
        "user" : "examplename",
    }'

Hi,

Jobs can’t be passed additional data directly, the command would need to be able to retrieve the required data from some other source, e.g. a database.

It sounds like you may want a background job processor, like Celery in Python, or Sidekiq in Ruby.

I’m not sure of the equivalent in PHP, I think Laravel has queues? That way, you could set up your own web endpoint that receives the data you require and then queues up the job to be run, usually on a separate Background Worker.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.