How to pass a variable while calling a River job from Externally

I am able to successfully run a River job using an API call externally. Python is my language. I am not sure how to pass a variable while running the River Job. I want the variable passed from API call to be set into a River Environment Variable.

import requests

import json

url = “https://console.rivery.io/api/run

payload = json.dumps({

“river_id”: “555555555555555555”

})

headers = {

‘Content-Type’: ‘application/json’,
‘Authorization’: ‘Bearer AccesToken’
}

response = requests.request(“POST”, url, headers=headers, data=payload)

print(response.text)

Hi @kishore,

Here is our documentation on working with variables in Python: Python Logic Step - Python

Note - environment variables are read-only, and cannot be edited from a python step.

Would you mind providing some more details about your use case? Maybe I can help point you in the right direction if I understand your goals a bit more.

Best,
Taylor

Hi @taylor.mcgrath , thank you very much for your reply.

I need to trigger River Jobs event based rather a specific time of the day. I could not find any event based scheduler inside Rivery.

In order to achieve above goal I am successfully able to trigger river jobs through API call as mentioned in above post. But I do not know how to pass a variable which can be used inside the triggered river job ( for example the file name which needs to be ingested or the table name to which loading to happen )

Please see if you can help.

Thank you very much.

Hi @kishore,

Unfortunately Rivery doesn’t natively support event-based triggers. Just to confirm - this is python you are running outside of Rivery?

If that’s the case, you can leverage this endpoint to update a river variable (only supported for logic rivers at the moment.) You can however pass variables from logic into source to target river variables, explained here.

So the flow could look something like:

  1. API call to update logic river variable
  2. API call to run logic river (that is configured with a source to target step to pass the variables as described in the link above)

Hope this helps,
Taylor

Thank you very much for your help. Right, we will call the API using Python outside of Rivery.

The use case is to Execute a River ingestion template to load for example 200 files into corresponding 200 tables in a target Database. We would like to have a River ingestion template/framework to be triggered externally as soon as files arrive on AWS S3.