BIM 360 API-Forge应用-getUsers返回“此帐户不存在”]]

问题描述 投票:0回答:1

这里是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."}

这是我所做的更改的列表:

  1. 已更改config.py中我的BIM 360 / Forge帐户的相关信息”
  2. forge_da.py中为getUsers()添加了一个模块
  3. 相应地修改了getToken(),以便'scope':'account:read'
  4. 我已检查每个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
    

非常感谢您的帮助。提前致谢!约瑟夫·弗伦德

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

python autodesk forge
1个回答
0
投票

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

resp = requests.get(Forge_BASE_URL+'/hq/v1/accounts/:account_id/users', headers = {'Authorization': 'Bearer '+ config.token}, json={'account_id' : Forge_ACCOUNT_ID})
© www.soinside.com 2019 - 2024. All rights reserved.