0

I've got the below error when I have tried to get the Site collection and site IDs. What could be the cause? Any help would be really appreciated.

var getMessage = new HttpRequestMessage(HttpMethod.Get, "https://www.onenote.com/api/beta/myorganization/siteCollections/FromUrl(url='https://123.sharepoint.com/teams/techs'");

{
  StatusCode: 400,
  ReasonPhrase: 'Bad Request',
  Version: 1.1,
  Content: System.Net.Http.StreamContent,
  Headers: {
    OData - Version: 4.0 Cache - Control: private Server: Microsoft - IIS / 8.5 X - AspNet - Version: 4.0.30319 X - Powered - By: ASP.NET X - Powered - By: ASP.NET Date: Sun, 17 Jan 2016 19: 59: 05 GMT Content - Length: 168 Content - Type: application / json;
    charset = utf - 8;
    odata.metadata = minimal;
    odata.streaming = true;
    IEEE754Compatible = false
  }
}
halfzebra
  • 6,771
  • 4
  • 32
  • 47

2 Answers2

1

If that's a verbatim code snippet, looks like you're missing the closing parenthesis for the url parameter.

var getMessage = new HttpRequestMessage(HttpMethod.Get, "https://www.onenote.com/api/beta/myorganization/siteCollections/FromUrl(url='https://123.sharepoint.com/teams/techs')");
DianeD
  • 61
  • 6
0

Looks like you might be missing authentication-related headers.

http://blogs.msdn.com/b/onenotedev/archive/2015/06/11/and-sharepoint-makes-three.aspx

Jorge Aguirre
  • 2,787
  • 3
  • 20
  • 27
  • I have below 3 delegated permissions for the APP 1. Create pages in onenote note book 2. View and modify onenote note books 3.View and modify onenote notebooks in your organization – Karthick Pk Jan 25 '16 at 23:20
  • Do I need provide any other permissions ? – Karthick Pk Jan 25 '16 at 23:42
  • If you were using the wrong scopes, the API would let you know in the JSON payload. Could you share the value of the X-CorrelationId header in the HTTP response? – Jorge Aguirre Jan 25 '16 at 23:44
  • Do we get X-Correlation Id for this call. I'm not seeing it. This is the error I see when I Jason parse "{\r\n \"error\":{\r\n \"code\":\"20143\",\"message\":\"The OData query is invalid. Bad Request - Error in query syntax.\",\"@api.url\":\"http://aka.ms/onenote-errors#C20143\"\r\n }\r\n}" – Karthick Pk Jan 26 '16 at 00:08
  • 1
    Hi Jorge, I have missed a parenthesis in the call. Now it works. Thanks a lot for your help. – Karthick Pk Jan 26 '16 at 18:45