Hello, I receive an error while calling the api via the webservice in a survey workflow and also by using an external python script: {"errorMessage":"invalid_client","errorCode":"AUTH_6.0"}
I have set the api token as authentication. Any idea what causes the error? Is it possible that I can create an api token, but have no permission to use it?
This is the python script (not incl. my ids and token):
import requests
def copy_survey(api_token, data_center, owner_id, template_id):
# Construct the URL
url = f'https://{data_center}.qualtrics.com/API/v3/survey-definitions'
# Headers for the request
headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
# Data (payload) of the POST request
data = {
"SurveyName": "Copied Survey",
"SurveyDescription": "This is a survey copied from a template.",
"ProjectCategory": "Academic",
"SurveyOwnerID": owner_id,
"SurveyTemplateID": template_id
}
# Make the POST request
response = requests.post(url, json=data, headers=headers)
# Check if the request was successful
if response.status_code == 200:
print("Survey copied successfully!")
return response.json() # Return the JSON response from the API
else:
print("Failed to copy the survey. Status code:", response.status_code)
return response.text # Return the error response if not successful
# Replace the following variables with your actual data
API_TOKEN = 'your_api_token_here'
DATA_CENTER = 'your_data_center_id_here' # e.g., 'ca1', 'eu', 'us', etc.
OWNER_ID = 'your_qualtrics_user_id'
TEMPLATE_ID = 'template_survey_id_to_copy'
# Call the function to copy the survey
response_data = copy_survey(API_TOKEN, DATA_CENTER, OWNER_ID, TEMPLATE_ID)
print(response_data)