繁体   English   中英

带有OneDrive API的Microsoft Graph,邀请:失败,返回不支持的细分类型

[英]Microsoft Graph with OneDrive API, invite : fail with Unsupported segment type

到目前为止,我已经使用jquery发送了“复制项目”请求(POST / me / drive / items // copy),但是,如果我尝试添加权限(POST / drive / items // invite),则会收到“不支持的细分类型”错误。

API文档:graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_invite

(我复制了两个函数进行比较)

 // working:
    copyFile:function(id, folderId){
            // https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_copy
            // POST /me/drive/items/<id>/copy
            var endpointUrl = 'https://graph.microsoft.com/v1.0/me/drive/items/'+id+'/copy';
            var data={};
            data.parentReference={'id':folderId}
            $.ajax({
                 beforeSend: function(xhrObj){
                    xhrObj.setRequestHeader("Content-Type","application/json");
                    xhrObj.setRequestHeader("Accept","application/json");
                },
                processDate: false,
                datatype : "json",
                method: "POST",
                //http://stackoverflow.com/questions/13956462/jquery-post-sends-form-data-and-not-json 
                data: JSON.stringify(data),
                url: endpointUrl,
                contentType : 'application/json',
                headers : { "authorization" : "Bearer " + token }
            }).success(function(data) {
                alert('success!')
            });
        },

    ///NO WORKING ?
    invite:function(id, user){
        // http://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_invite
        // POST /drive/items/<id>/invite
        var endpointUrl = 'https://graph.microsoft.com/v1.0/drive/items/'+id+'/invite';

        data={
            "requireSignIn": true,
            "sendInvitation": false,
            "roles": "read",
            "recipients": [  { "email": user }],
            "message": "NO MESSAGE ?"   
        }
        $.ajax({
            beforeSend: function(xhrObj){
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Accept","application/json");
            },
            datatype : "json",
            method: "POST",
            data: JSON.stringify(data),
            url: endpointUrl,
            contentType : 'application/json',
            headers : {"authorization" : "Bearer " + token}
        }).success(function(data) {
            alert( 'success!')
        });

API返回:

{
  "error": {
    "code": "BadRequest",
    "message": "Unsupported segment type. ODataQuery: drive/items/***********/invite",
    "innerError": {
      "request-id": "********",
      "date": "2016-09-14T09:01:32"
    }
  }
}

我错过了什么 ?

看来v1.0版本目前无法使用。 我使用以下网址交换到Beta:

var endpointUrl = 'https://graph.microsoft.com/beta/me/drive/items/'+id+'/invite';

而且有效

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM