如何使用Autodesk Data Management API获取文件列表

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

我在我的平台上使用Laravel后端。我已经能够得到一个三脚标记,但是当我试图获得用户的集线器列表时,响应与example完全不同。

    $client = new Client(); //GuzzleHttp\Client     
    $response = $client->request('GET', 'https://developer.api.autodesk.com/project/v1/hubs', [
        'headers' => [
            'Authorization' => 'Bearer '.$obj->access_token
            'x-user-id' => $userObj->userId
        ]
    ]);

我已确认用户ID和令牌已正常发送。但是,我得到的回应与示例完全不同。

object(GuzzleHttp\Psr7\Response)#611 (6) {
  ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>string(2) "OK"
  ["statusCode":"GuzzleHttp\Psr7\Response":private]=>int(200)
  ["headers":"GuzzleHttp\Psr7\Response":private]=>array(11) {
  ["Content-Type"]=>
array(1) {
  [0]=>
  string(24) "application/vnd.api+json"
}
["Date"]=>
array(1) {
  [0]=>
  string(29) "Tue, 26 Mar 2019 19:55:02 GMT"
}
["Referrer-Policy"]=>
array(1) {
  [0]=>
  string(24) "origin-when-cross-origin"
}
["Server"]=>
array(1) {
  [0]=>
  string(8) "forge-dm"
}
["Strict-Transport-Security"]=>
array(1) {
  [0]=>
  string(35) "max-age=31536000; includeSubDomains"
}
["X-Content-Type-Options"]=>
array(1) {
  [0]=>
  string(7) "nosniff"
}
["X-Frame-Options"]=>
array(1) {
  [0]=>
  string(4) "DENY"
}
["X-Request-Id"]=>
array(1) {
  [0]=>
  string(36) "b747247f-b93b-4557-ae11-821b76fc8bba"
}
["X-XSS-Protection"]=>
array(1) {
  [0]=>
  string(13) "1; mode=block"
}
["Content-Length"]=>
array(1) {
  [0]=>
  string(4) "1087"
}
["Connection"]=>
array(1) {
  [0]=>
  string(10) "keep-alive"
}
}

["headerNames":"GuzzleHttp\Psr7\Response":private]=>array(11) {
["content-type"]=>string(12) "Content-Type"
["date"]=>string(4) "Date"
["referrer-policy"]=>string(15) "Referrer-Policy"
["server"]=>string(6) "Server"
["strict-transport-security"]=>string(25) "Strict-Transport-Security"
["x-content-type-options"]=>string(22) "X-Content-Type-Options"
["x-frame-options"]=>string(15) "X-Frame-Options"
["x-request-id"]=>string(12) "X-Request-Id"
["x-xss-protection"]=>string(16) "X-XSS-Protection"
["content-length"]=>string(14) "Content-Length"
["connection"]=>string(10) "Connection"
}
  ["protocol":"GuzzleHttp\Psr7\Response":private]=>string(3) "1.1"
  ["stream":"GuzzleHttp\Psr7\Response":private]=>object(GuzzleHttp\Psr7\Stream)#635 (7) {
["stream":"GuzzleHttp\Psr7\Stream":private]=>
resource(47) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=>
NULL
["seekable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["readable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["writable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["uri":"GuzzleHttp\Psr7\Stream":private]=>
string(10) "php://temp"
["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
array(0) {
    }
  }
}
autodesk-forge autodesk-data-management
1个回答
0
投票

响应是不同的,因为您在标头中使用了x-user-id,这应该使用2脚标记,而不是文档中所述的3脚标记(因为您已经拥有了要获取数据的特定用户从)。

x-user-id -----在两条腿的身份验证上下文中,该应用程序可以访问SaaS集成UI中管理员指定的所有用户。通过提供此标头,API调用将仅限于代表指定的用户执行操作。

这将只为您提供BIM 360环境的项目,而没有项目类型差异的标识符。您是否已经设置了集成?

我会建议: - 3个Legged令牌 - GET Hubs,只有你头部的令牌

应该给你一个类似于例子的回应。如果您要查找的数据来自BIM 360,则必须确保已启用帐户中的自定义集成。

© www.soinside.com 2019 - 2024. All rights reserved.