Используя jquery, до сих пор мне удалось отправить запрос на копирование (POST/me/drive/items // copy), , однако, если я попытаюсь добавьте разрешение (POST/drive/items // invite), я получаю ошибку «Неподдерживаемый тип сегмента».Microsoft Graph with OneDrive API приглашает: сбой с неподдерживаемым типом сегмента
В 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"
}
}
}
ли я что-то пропустил?