这里是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
我正在使用xiaodongliang的上述存储库作为起点,但是我不断收到以下错误:
Get Users Failed! status = 404 ; message = {"code":1004,"message":"this account doesn't exist."}
这是我所做的更改的列表:
我检查了每个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
任何帮助将不胜感激。提前致谢! 约瑟夫·弗伦德
答案 0 :(得分:0)
哇,我发现了我的错误。我更改了以下行:
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})
发布问题迫使我去实际研究它。感谢您的帮助!