需要使用BIM 360 API中的'services”端点来添加或更新与角色相关联的服务。例如,以下代码示例演示如何使用services端点更新行业角色'architect'所关联的服务。
import requests
import json
# Set up headers and session authentication
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer '}
session = requests.Session()
# Define the new services to be associated with the 'architect' role
new_services = {"services": [
{"id": ""},
{"id": ""}
]}
# PATCH the services using the services endpoint
response = session.patch('https://developer.api.autodesk.com/bim360/admin/v1/projects//services/roles/architect', headers=headers, data=json.dumps(new_services))
# Ensure the response was successful
if response.status_code != 200:
print("Error updating services:", response.content)
else:
print("Services updated successfully")
在这个示例中,您需要替换'