将问题指派给与 BIM 360 一起使用的特定用户或团队是很常见的操作。可以使用 Forge API 通过编写代码来实现这一点。
以下是一些可以基于 Forge API 接口来指派问题的代码示例:
//首先,需要一个API调用凭据
const FORGE_CLIENT_ID = process.env.FORGE_CLIENT_ID || 'your_client_id';
const FORGE_CLIENT_SECRET = process.env.FORGE_CLIENT_SECRET || 'your_client_secret';
const FORGE_CALLBACK_URL = process.env.FORGE_CALLBACK_URL || 'http://localhost:3000/api/forge/callback/oauth';
//接下来,需要授权访问您的BIM 360账户
const { AuthClientTwoLegged } = require('forge-apis');
const bim360Client = new AuthClientTwoLegged(
FORGE_CLIENT_ID,
FORGE_CLIENT_SECRET,
['data:read', 'data:write', 'bucket:read', 'bucket:update'],
true
);
//然后,需要获取与指定名称相匹配的团队,以将问题分配给该团队成员
const { ProjectTeamsApi } = require('forge-apis');
const projectTeamsApi = new ProjectTeamsApi();
const teamResponse = await projectTeamsApi.getTeams(projectId, { name: teamName }, bim360Client, bim360Client.getCredentials());
if (teamResponse.body.data.length === 0) throw new Error(`Team ${teamName} not found in project ${projectId}`)
const teamId = teamResponse.body.data[0].id;
//最后,使用 Issue API 中的“PATCH”功能将指定的问题分配给您已获得访问权限的具体用户或团队
const { IssuesApi } = require('forge-apis');
const issuesApi = new IssuesApi();
const assignee = { 'type': 'UserId', 'id': assignToUserId };
const issuePatchResponse = await issuesApi.patchIssue(projectId, issueId, { 'assigned_to': assignee }, bim360Client, bim360Client.getCredentials());
上一篇:BIM360问题-快照URN图像
下一篇:BIM360问题SortBy()