import requests
import json
# Set your access token and Zoho People API base URL
access_token = '1000.XXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXX'
api_base_url = 'https://people.zoho.in/people/api/'
# Set the form name and data to be inserted
form_link_name = 'travelrequest'
record_data = {
"EmployeeID": "ABCCC 1",
"EmployeeDepartment": "HR",
"PlaceOfVisit": "Delhi",
"ExpectedDateOfDeparture": "16-Jun-2023",
"ExpectedDateOfArrival": "01-Jun-2023",
"PurposeOfVisit": "visit",
"Expectedduration": "23",
"IsBillable": "No",
"CustomerName":"bob"
# Add more fields as necessary
}
# Prepare the API URL# Prepare the API URL
api_url = f'{api_base_url}forms/json/{form_link_name}/insertRecord'
# Prepare the request headers
headers = {
'Authorization': f'Zoho-oauthtoken {access_token}',
'Content-Type': 'application/json',
}
# Prepare the request payload
payload = {
'data': [record_data],
}
# Send the request
response = requests.post(api_url, headers=headers, json=payload)
print(response.content)
# Check the response status
if response.status_code == 201:
print('Record inserted successfully.')
else:
print('Error inserting record.')
print(f'Status Code: {response.status_code}')
print(f'Response: {response.text}')