In my article, Programming with the Office 365 APIs General Availability Release, I showed how to use the Discovery Service to reach the "Contacts" capability and then use that endpoint to return Exchange online contacts. Subsequently, Andrew Connell was using the article as a reference and tripped over a "gotcha" whereby leaving the training slash off of the Discovery Service endpoint causes the API call to fail. So, it's the difference between these two things in the article.
const string DISCOVERY_ENDPOINT = "https://api.office.com/discovery/v1.0/me";
const string DISCOVERY_ENDPOINT = "https://api.office.com/discovery/v1.0/me/"
That's a real trap waiting for developers who are new to the Office 365 APIs.
There are two solutions to the problem:
- Obviously you could just be really careful and make sure to include the trailing slash.
- Make use of the FirstSignIn endpoint.
The FirstSignIn endpoint is designed to be the one truly-stable endpoint that you can call in the beginning and obtain the Discovery Service endpoint from that call. I explained the role of the FirstSignIn endpoint in this article, but if you had my contacts sample deployed to Azure at something like https://mycontacts.azurewebsites.net, then you would simply redirect the user to:
which would return the Discovery endpoint complete with the required trailing slash.