Discovery Service API Requires Trailing Slash

Scot Hillier

by Scot Hillier on 11/12/2014

Share this:

Article Details

Date Revised:

Applies to:
Development, discovery service API, Office 365 API, Office 365 programming

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 = "";

const string DISCOVERY_ENDPOINT = ""

That's a real trap waiting for developers who are new to the Office 365 APIs. 

There are two solutions to the problem:

  1. Obviously you could just be really careful and make sure to include the trailing slash.
  2. 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, then you would simply redirect the user to:

which would return the Discovery endpoint complete with the required trailing slash.

Topic: Development

Sign in with

Or register