Autodesk FORGE BIM 360 API - 无法修补用户

Autodesk FORGE BIM 360 API - Can't PATCH User

我正在尝试使用 Node.js 'forge-api' 包更新 BIM 360 用户 (active/inactive) 及其公司的状态。

此特定端点在当前 api 中尚不可用: https://forge.autodesk.com/en/docs/bim360/v1/reference/http/users-:user_id-PATCH/

基于已实现的端点 (patchItem),我将其复制并修改如下:

const { ApiClient } = require('forge-apis');

function patchUser(accountId, oauthClient, credentials, res, userId, companyId, status) {

     const body = {
         status: status,
         company_id: companyId
    }

    patchAPI(accountId, {}, oauthClient, credentials, body, userId)
        .then(data => {
            const { name, id, status, company_name } = data.body
            res.json({name: name, id: id, status: status, company: company_name})
        })
        .catch(error => {
            res.json(error)
        })

}

async function patchAPI(hubId, opts, oauth2client, credentials, body, userId) {
    opts = opts || {};
    var postBody = body;

    // verify the required parameter 'hubId' is set
    if (hubId == undefined || hubId == null) {
        return Promise.reject("Missing the required parameter 'hubId' when calling patchAPI with users");
    }

    // verify the required parameter 'userId' is set
    if (userId == undefined || userId == null) {
        return Promise.reject("Missing the required parameter 'userId' when calling  patchAPI with users");
    }

    // verify the required parameter 'body' is set
    if (body == undefined || body == null) {
        return Promise.reject("Missing the required parameter 'body' when calling patchAPI with users");
    }

    var pathParams = {
        'hub_id': hubId,
        'user_id': userId
    };
    var queryParams = {};
    var headerParams = {
        'x-user-id': opts.xuserid
    };
    var formParams = {};

    var contentTypes = ['application/vnd.api+json'];
    var accepts = ['application/vnd.api+json', 'application/json'];
    var returnType = null;

    return ApiClient.instance.callApi(
        '/hq/v1/accounts/{hub_id}/users/{user_id}', 'PATCH',
        pathParams, queryParams, headerParams, formParams, postBody,
        contentTypes, accepts, returnType, oauth2client, credentials
    );

}

很遗憾,它没有修改用户。返回的用户与之前完全一样,就好像 Body 部分被完全忽略了一样。

我知道我所有的 ID 都是正确的,因为我收到状态 200 并且返回用户(未更改)并且我可以使用 Postman 成功修补用户。

不确定我遗漏了什么,但我们将不胜感激

'forge-apis' 包中提供的 PATCH 端点用于数据管理 API 并且它们的 Content-Type 正文必须 'application/vnd.api+json'

但是对于 BIM 360 API,Content-Type 必须是 'application/json'。 更改下面的行后一切正常。

var contentTypes = ['application/json'];