是的,BIM 360提供了一种方法来检索授权用户的account_id。下面是一个示例代码:
import requests
def get_account_id(token):
# 设置API端点URL
url = 'https://developer.api.autodesk.com/bim360/admin/v1/accounts'
# 设置请求头
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
# 发送GET请求
response = requests.get(url, headers=headers)
# 解析响应
if response.status_code == 200:
data = response.json()
account_id = data['data'][0]['id'] # 假设只有一个账户,获取第一个账户的account_id
return account_id
else:
print(f'Error: {response.status_code} - {response.text}')
return None
# 使用示例
token = 'YOUR_ACCESS_TOKEN'
account_id = get_account_id(token)
if account_id:
print(f'Account ID: {account_id}')
在上面的示例中,我们使用了Python的requests库来发送HTTP请求。我们首先设置了API端点URL,然后设置了请求头,包括授权令牌。最后,我们发送一个GET请求,并解析响应以获取account_id。请确保将YOUR_ACCESS_TOKEN
替换为您自己的访问令牌。
上一篇:BIM 360 Field API Issues V1:使用Postman进行GET请求完美运行,在RestSharp中响应“未授权”。
下一篇:BIM 360模型属性API返回禁止访问(projects/:projectId/diffs:batch-status)