Reputation: 226
I am trying to fetch a user's Contacts using the Microsoft Graph SDK. I am able to get the user details using graphClient.me()
, but when I try to get a list of contacts I am getting an error:
Graph SDK ERROR :
Error from data task :
Error Domain=com.microsoft.graph.errors
Code=400 "bad request"
UserInfo={
NSLocalizedDescription=bad request,
error= AuthenticationError : Error authenticating with resource
}
Graph SDK ERROR : Caused by request <NSMutableURLRequest: 0x1738bc70> {
URL: https://graph.microsoft.com/v1.0/me/contacts
}
My Code:
self.graphClient.me().contacts().request().getWithCompletion {
(_ contacts: MSCollection?,
_ nextRequest: MSGraphUserContactsCollectionRequest?,
_ error: Error?) in
if error == nil {
print("contacts \(contacts)")
}
else {
print("error \(error?.localizedDescription)")
}
}
My Scopes:
let SCOPES = ["openid", "profile","User.Read","Contacts.Read"]
Upvotes: 1
Views: 491
Reputation: 33094
The /contacts
endpoint requires that the user
has an accessible Exchange Mailbox. If the user doesn't have a mailbox provisioned in Exchange Online for this tenant, several endpoints that rely on Exchange will fail (/contacts
, /events
, /messages
, etc.).
Upvotes: 1