I am trying to import contacts via api using python. But I am getting 401 error as :-
{"meta":{"httpStatus":"401 - Unauthorized","error":{"errorMessage":"No default directory found for brand: xyz.","errorCode":"xyz"},"requestId":"xyz"}}
My code is given below :-
import requests
import json
dict_Contacts = [
{
"firstName": "xyz",
"lastName": "xyz",
"email": "xyz@xyz.com",
"language": "xyz",
"unsubscribed":1,
"externalReference":"xyz",
"embeddedData": {"ExampleField1":"xyz", "ExampleField2":"xyz"}
}
]
Token = 'My_Token'
MailingListID = 'My_Mailing_List'
dataCenter = 'My_Data_Center'
url = "https://{0}.qualtrics.com/API/v3/mailinglists/{1}/contactimports/".format(dataCenter, MailingListID)
headers = {
'x-api-token': Token,
'contentType':'application/json'
}
json_string = json.dumps(dict_Contacts)
files = {'contacts': ('contacts', json_string, 'application/json')}
request = requests.post(url, headers=headers, json={'contacts':dict_Contacts})
print(request.text)
My token and path are correct. Can anybody please tell me what exactly the error means? (as No default directory found for brand) and how to resolve this issue.
401 error for contact imports
Best answer by NiC
Hi Rasika,
The error hints that your account has XM Directory. The above API call you are doing is not supported of XM directory users(as XM directory users can have multiple directories).
You can use this call to import contacts into XM directory - https://api.qualtrics.com/api-reference/reference/contactImports.json/paths/~1directories~1%7BdirectoryId%7D~1mailinglists~1%7BmailingListId%7D~1transactioncontacts/post
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
