Search code examples
office365office365apiazure-ad-graph-apimicrosoft-graph-api

Microsoft Graph API Endpoint "microsoft.graph.createLink" Returning 400 Error


I have tried sending the following HTTP request based on the new Microsoft Graph API v1:

POST https://graph.microsoft.com/v1.0/groups/c694da84-3f9f-4bac-9491-c2775fc39f65/drive/items/012YPM4EKO23JQWLSNYJG2DG3ZAULBDCIS/microsoft.graph.createLink HTTP/1.1
Authorization: Bearer <access-code> (filled in with valid access token)
Host: graph.microsoft.com
Content-type: application/json
Content-Length: 53

{
  "type": "edit",
  "scope": "Files.ReadWrite"
}

My URL follows the following format: https://graph.microsoft.com/v1.0/groups/<group-id>/drive/items/<item-id>/microsoft.graph.createLink

I get the following 400 error:

HTTP/1.1 400 Bad Request

{
  "error": {
    "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
    "message": "The parameter scope does not exist in method createLink.",
    "innerError": {
      "request-id": "nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn",
      "date": "2015-11-30T23:55:56"
    }
  }
}

I'm kind of confused, because according to the following documentation (that I think is up to date), scope is required in the request body: Microsoft Graph - Create a sharing link for an item


Solution

  • Camden,

    Sorry for the late response here. Yes - we have a bug here, for which a fix is in the process of being deployed. I'll try and get an ETA for when this might complete. Anyway, as soon as this completes this request should start working. That said, there is an error in your request. The "scope" parameter must be set to either 'organization' or 'anonymous'. I'll file an issue on GitHub to fix the docs to mention this.

    Hope this helps,