Retrieve Future Rosters - Python
import requests # Import requests HTTP library to access the server
import json # Import JSON
import time # Import the time library
# Get the current timestamp as an integer
current_timestamp = int(time.time())
# Deputy install URL, update to your own
url = "https://suitehotel.au.deputy.com/api/v1/resource/Roster/QUERY"
# Use the current_timestamp variable in the payload. This defines the query on the Deputy side.
payload = json.dumps({
"search": {
"s1": {
"field": "StartTime",
"type": "gt",
"data": str(current_timestamp) # Convert the integer timestamp to a string
}
}
})
#set headers including security token, the dots should be replaced with your bearer token from your install.
headers = {
'Authorization': 'Bearer ••••••',
'Content-Type': 'application/json'
}
#define the post to the server
response = requests.request("POST", url, headers=headers, data=payload)
#print the response in console
print(response.text)
Sample Python code that will return all future rosters based on the current timestamp at execution.
Updated 12 months ago