shared_link 文件共享为空 api 框节点 js sdk

shared_link null on file share api box node js sdk

我通过使用方框 api https://developer.box.com/v2.0/reference#get-shared-link 得到 shared_link null 无法弄清楚我在做什么? 这是我的代码

function requestCallback(err, res, body) {
    console.log(body);
    console.log("requestCallback");
}

var accessToken = 'tvXSjyJM3XDh0YWss72ciYdXDtFNQeEh';
var r = request.put({
    url: 'https://api.box.com/2.0/files/205773246434?fields=shared_link',
    headers: { 'Authorization': 'Bearer ' + accessToken }
}, requestCallback);

var form = r.form();
form.append('access', 'open');

并得到回应

{"type":"file","id":"205773246434","etag":"0","shared_link":null}

我使用了 box-node-sdk 并确保该应用 "user-enabled" 并且它似乎可以正常工作。

var BoxSDK = require('box-node-sdk');
var fs = require('fs');
var path = require('path');

var CLIENT_ID = 'xxxx',
  CLIENT_SECRET = 'xxxx',
  PUBLIC_KEY_ID = 'xxxx',
  PRIVATE_KEY_PATH = 'xxxx',
  PRIVATE_KEY_PASSPHRASE = 'xxxx',
  ENTERPRISE_ID = 'xxxx';

var sdk = new BoxSDK({
    clientID: CLIENT_ID,
    clientSecret: CLIENT_SECRET,
    appAuth: {
      keyID: PUBLIC_KEY_ID,
      privateKey: fs.readFileSync(path.resolve(__dirname, PRIVATE_KEY_PATH)),
      passphrase: PRIVATE_KEY_PASSPHRASE
    }
});

var client = sdk.getAppAuthClient('enterprise', ENTERPRISE_ID);

client.files.get('xxxx', {fields: 'shared_link'}, function(err, data)         {
  console.log(data.shared_link.url);
});