403:在阅读更新Sharepoint列表时,Sharepoint在线休息api出现禁止错误。

问题描述 投票:0回答:1

我试图连接我的nodejs应用程序,以更新从 https:/xyz.sharepoint.comsitesdev_apiweblistsGetByTitle。('listname')。

使用sharepoint addin验证,应用程序被注册到xyz.sharepoint.com注册页面,并将应用程序的manifest文件权限设置为fullcontrol。

<AppPermissionRequests AllowAppOnlyPolicy="true">
  <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl"/>
</AppPermissionRequests>

正在使用以下代码。

          var sprequest=require('sp-request')
          let spr = sprequest.create({          
                clientId:'clientid',  
                clientSecret:'client secret'  
            });
            spr.requestDigest('https://xyz.sharepoint.com/sites/dev')
            .then(digest => {
              return spr.post('https://xyz.sharepoint.com/sites/dev/_api/web/lists/GetByTitle(\'listname\')', {
                body: {
                  '__metadata': { 'type': 'SP.List' },
                  'Title': 'TesList'
                },

                headers: {
                  'X-RequestDigest': digest,
                  'X-HTTP-Method': 'MERGE',
                  'IF-MATCH': '*'
                }
              });
            })
            .then(response => {
              if (response.statusCode === 204) {
                console.log('List title updated!');
              }
            }, err => {
              if (err.statusCode === 404) {
                console.log('List not found!');
              } else {
                console.log(err);
              }
            });

我能够获得身份验证令牌,但向sharepoint在线api(代码中的sp.post部分)发出的POST请求以403:forbidden错误失败。You do not have permission to perform this action or access this resource.")我也试过用postman,结果总是出现同样的错误。

在sharepoint在线网站上做的应用注册,如文章中提到的------。https:/medium.com@anooptaccessing-sharepoint-data-using-postman-sharepoint-rest-api-76b70630bcbf。

读取列表也失败了,通过代码和postman也出现了同样的错误。

node.js sharepoint-online http-status-code-403 sharepoint-api
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.