title: 401 Error getting a list of service endpoints using REST API from TFS extension
body: <p>I have developed a TFS extension for TFS 2017 on premises.
  I need to get a list of the <a href="https://www.visualstudio.com/en-us/docs/integrate/api/endpoints/endpoints" rel="nofollow noreferrer">service endpoint</a> within a project</p>
  
  <p>I am using the following code inside a TFS extension (<a href="https://www.visualstudio.com/en-us/docs/integrate/extensions/reference/targets/overview" rel="nofollow noreferrer">code-hub</a>)</p>
  
  <pre><code>private callTfsApi() {
      const vsoContext = VSS.getWebContext();
      let requestUrl = vsoContext.host.uri
          + vsoContext.project.id
          + "/_apis/distributedtask/serviceendpoints?api-version=3.0-preview.1";
  
      return VSS.getAccessToken().then(function (token) {
          // Format the auth header
          const authHeader = VSS_Auth_Service.authTokenManager.getAuthorizationHeader(token);
  
          // Add authHeader as an Authorization header to your request
          return $.ajax({
              url: requestUrl,
              type: "GET",
              dataType: "json",
              headers: {
                  "Authorization": authHeader
              }
          }).then((response: Array&lt;any&gt;) =&gt; {
  
              console.log(response);
          });
      });
  }
  </code></pre>
  
  <p>On every request the server responds with a status of 401 (Unauthorized).</p>
  
  <p>If I use postman and basic authentication the call to the service endpoints APIs works. </p>
  
  <p>Also, using the same code but a different API call (<a href="https://www.visualstudio.com/en-us/docs/integrate/api/tfs/projects" rel="nofollow noreferrer">projects</a>) works.</p>
  
  <pre><code>let requestUrl = vsoContext.host.uri + "_apis/projects?api-version=1.0"; 
  </code></pre>
  
  <p>Is there some sort of known bug related to the service endpoints APIs or maybe the extension must specify a <a href="https://docs.microsoft.com/en-us/vsts/extend/develop/manifest#scopes" rel="nofollow noreferrer">scope</a>? (not sure which one to include though)</p>