Good day,
I am attempting to use the survey123 create report api to run some tests. I am using the documentation found here https://developers.arcgis.com/survey123/api-reference/rest/report/#create-report to run a post request in python.
My code is below and gives me an error message
import requests
# Define the parameters
survey_id = "4821fdadbd0f48c9b060615e9xxxx" # Replace with your actual Survey ID
template_item_id = "da82c957fe134248b356e899acxxxxx" # The ID of your report template item
token = "token"
# Authentication token from ArcGIS Online or your Portal
# Define the report request payload
payload = {
"f": "json",
"portalUrl": "https://mygis/portal",
"queryParameters": {"objectIds":"532","orderByFields":"||last_edited_date DESC, objectid ASC"},
"templateItemId": template_item_id,
"outputReportName": "Test report",
"surveyItemId": survey_id,
"featureLayerUrl": "https://prodgis.lla.com/server/rest/services/Hosted/service_891bd7a80776437781ca20e1e3a0be28/Feature...",
"outputFormat": "docx", # or "docx"
"token": token
}
# Submit the report job request
url = f"https://survey123.arcgis.com/api/featureReport/createReport/submitJob"
response = requests.post(url, data=payload)
# Process the response
if response.status_code == 200:
data = response.json()
if 'jobId' in data:
print("Report job submitted successfully!")
print("Job ID:", data['jobId'])
# Optionally, you can check the job status or get the result when complete
else:
print("Failed to submit report job:", data)
else:
print("Error submitting report job:", response.status_code, response.text)
error message
Failed to submit report job: {'error': {'message': 'The "queryParameters" must include at least one of the following: "objectIds", "where", or "geometry".', 'code': '017'}, 'success': False}
Any help would be appreciated
Is objectIds meant to be a list?
"objectIds": [532]
I'm not sure how you want to achieve this, but you might try using the arcgis API for python: https://developers.arcgis.com/survey123/guide/create-reports-using-the-arcgis-api-for-python/
I found this to be much easier.