BIM 360 API - Forge App - getUsers 返回"This account doesn't exist"



这里是RESTful API的新手,所以这可能是一个愚蠢的问题:我正试图通过以下链接查询BIM 360帐户中的所有用户:https://forge.autodesk.com/en/docs/bim360/v1/reference/http/users-GET/

https://github.com/Autodesk-Forge/design.automation-python-tutorial

我正在使用肖栋梁的上述存储库作为起点,但我一直得到以下错误:

Get Users Failed! status = 404 ; message = {"code":1004,"message":"this account doesn't exist."}

以下是我所做的更改列表:

  1. config.py中更改了我的BIM 360/Forge帐户的相关信息
  2. forge_da.py中为getUsers((添加了一个模块
  3. 相应地修改了getToken((,以便"scope":"account:read">

我已经检查了每个ID、令牌和秘密是否正确,并在BIM 360账户中添加了一个自定义集成。不确定我在这里错过了什么。请参阅下面添加和更改的模块:

def getToken():
"""Obtain Forge token given a client id & secret"""
req = { 'client_id' : Forge_CLIENT_ID, 'client_secret': Forge_CLIENT_SECRET, 'grant_type' : 'client_credentials','scope':'account:read'}
resp = requests.post(Forge_BASE_URL+'/authentication/v1/authenticate', req)
if resp.status_code == 200:
config.token = resp.json()['access_token']
return config.token
else:
print('Get Token Failed! status = {0} ; message = {1}'.format(resp.status_code,resp.text) )
return None
def getUsers():
"""Query all BIM 360 Users in given Account"""
print(Forge_ACCOUNT_ID, config.token)
resp = requests.get(Forge_BASE_URL+'/hq/v1/accounts/:account_id/users', headers = {'Authorization': 'Bearer '+ config.token}, json={'account_id' : Forge_ACCOUNT_ID})
if resp.status_code == 200:
config.users = resp.json()
return config.users
else:
print('Get Users Failed! status = {0} ; message = {1}'.format(resp.status_code,resp.text) )
return None

非常感谢您的帮助。提前感谢!Joseph Freund

哇,我发现了我的错误。我更改了以下行:

resp = requests.get(Forge_BASE_URL+'/hq/v1/accounts/:account_id/users', headers = {'Authorization': 'Bearer '+ config.token}, json={'account_id' : Forge_ACCOUNT_ID})

至:

resp = requests.get(Forge_BASE_URL+'/hq/v1/accounts/' + Forge_ACCOUNT_ID + '/users', headers = {'Authorization': 'Bearer '+ config.token})

发布这个问题迫使我认真地看了看。谢谢你的帮助!

相关内容

最新更新