This topic was automatically generated from Slack. You can find the original thread here.
I need help with scheduled tasks. I want to iterate through a list and schedule tasks in the future from a list of events using python. What should my JSON payload look like using requests librayr?
Based on your question, it seems you are looking to schedule tasks in the future using Python and you are interested in what the JSON payload should look like when using the requests library. To schedule tasks in the future, you can use the Pipedream Schedule API which allows you to send POST requests to schedule new tasks. However, since you mentioned using Python and the requests library, I’ll provide you with a general structure of how the JSON payload might look like for scheduling tasks. Please note that the exact payload structure will depend on the API you’re interacting with. Here’s an example of what the JSON payload could look like when scheduling a task using the requests library in Python: import requests # This is a hypothetical URL for the scheduling API endpoint schedule_api_url = "https://api.your-scheduler.com/schedule" # Your list of events to schedule events_to_schedule = [ {"time": "2023-04-01T10:00:00Z", "task": "Task 1"}, {"time": "2023-04-02T11:00:00Z", "task": "Task 2"}, # Add more events as needed ] # Iterate through the list of events and schedule each one for event in events_to_schedule: payload = { "schedule_time": event["time"], # The time when the task should be executed "task_details": { "name": event["task"], # Include other task details as required by the scheduling API } } # Send the POST request with the JSON payload response = [requests.post](http://requests.post)(schedule_api_url, json=payload) # Check if the request was successful if response.status_code == 200: print(f"Task scheduled successfully: {event['task']}") else: print(f"Failed to schedule task: {event['task']}") # Note: Replace 'schedule_api_url' with the actual endpoint URL of your scheduling API. In this example, schedule_time and task_details are hypothetical keys that you would replace with the actual keys required by the scheduling API you are using. The [requests.post](http://requests.post) method is used to send a POST request with the JSON payload to the scheduling API endpoint. Please replace `
To assist you with the specific workflow scheduling API endpoint in Pipedream, I would need a bit more information about what you’re trying to achieve. Are you looking to programmatically create, update, or manage schedules for your workflows? Pipedream does offer a REST API that allows you to interact with your workflows, including scheduling operations. However, without direct access to the Pipedream documentation on their API endpoints, I can’t provide the exact details you need. I recommend checking the Pipedream API documentation for information on workflow scheduling endpoints. If you’re unable to find the information you need, or if you have further questions about how to use the API, please visit Pipedream Support for more detailed assistance.
Now if I add /schedule ot the end of the URL the above scheduled tasks endpoint, I get in the backend same message as if I used the inbuilt tooll to schedule
However, when I POST to normal endpoint without /schedule appended, get an error in workflow
thank you so much! For extra context, I’m trying to iterate through a list of things (dicts, python) and then schedule a different workflow depending on the “time” field in each of the dict items
Yep np thanks for sharing the additional info!
Okay, so this trigger accepts two paths in the URL: /schedule and /cancel - any other than that, including the root path (/) won’t be accepted