[英]Autodesk FORGE BIM 360 API - Can't PATCH User
I am trying to update the status of a BIM 360 user (active/inactive) and its Company using the Node.js 'forge-api' package.我正在尝试使用 Node.js 'forge-api' package 更新 BIM 360 用户(活动/非活动)及其公司的状态。
This particular endpoint is not available yet in the current api: https://forge.autodesk.com/en/docs/bim360/v1/reference/http/users-:user_id-PATCH/此特定端点在当前 api 中尚不可用: https://forge.autodesk.com/en/docs/bim360/v1/reference/http/users-:user_id-PATCH/
Based on implemented endpoints (patchItem) I duplicated it and modified as follows:基于已实现的端点 (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
);
}
Unfortunately it is not modifying the user.不幸的是,它没有修改用户。 The user is returned exactly as before, as if the Body part is completely ignored.用户返回时与之前完全一样,就好像 Body 部分被完全忽略了一样。
I know that all my Ids are correct because I receive a status 200 and user is returned (unchanged) and I can successfully PATCH the user with Postman.我知道我所有的 ID 都是正确的,因为我收到状态 200 并且返回用户(未更改)并且我可以成功地使用 Postman 修补用户。
Not sure what I am missing but any help would be much appreciated不知道我错过了什么,但任何帮助将不胜感激
The PATCH endpoints that are provided in the 'forge-apis' package are for the Data Management API and their Content-Type for the body must be 'application/vnd.api+json' 'forge-apis' package 中提供的 PATCH 端点用于数据管理 API 并且它们的正文内容类型必须是 'application/vnd.api+json'
However for the BIM 360 API the Content-Type must be 'application/json'.但是对于 BIM 360 API,Content-Type 必须是“application/json”。 After changing the line below everything is working fine.更改下面的行后,一切正常。
var contentTypes = ['application/json'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.