getManifest问题(forge-php-client)

时间:2017-12-22 18:25:41

标签: php autodesk-forge

DerivativesApi.getManifest方法或ManifestChildren.setRole方法似乎存在问题。

当我打电话给" $ apiInstance-> getManifest"时,我收到以下错误消息:

"调用DerivativesApi-> getManifest时出现异常:' role'的值无效,必须是' 2d',' 3d'中的一个, '图形','显示',' thumbnail'"

这是Stacktrace:

1 * \ ObjectSerializer.php(236):Autodesk \ Forge \ Client \ ObjectSerializer :: deserialize(Object(stdClass),&#39; \\ Autodesk \\ Forge ...&#39;,NULL)< / H1>

2 * \ ObjectSerializer.php(291):Autodesk \ Forge \ Client \ ObjectSerializer :: deserialize(Array,&#39; \\ Autodesk \\ Forge ...&#39;,NULL)\ n

3 * \ ObjectSerializer.php(236):Autodesk \ Forge \ Client \ ObjectSerializer :: deserialize(Object(stdClass),&#39; \\ Autodesk \\ Forge ...&#39;,NULL)< / H1>

4 * \ ObjectSerializer.php(291):Autodesk \ Forge \ Client \ ObjectSerializer :: deserialize(Array,&#39; \\ Autodesk \\ Forge ...&#39;,NULL)\ n

5 * \ DerivativesApi.php(403):Autodesk \ Forge \ Client \ ObjectSerializer :: deserialize(Object(stdClass),&#39; \\ Autodesk \\ Forge ...&#39;,Array)\ ñ

6 * \ DerivativesApi.php(336):Autodesk \ Forge \ Client \ Api \ DerivativesApi-&gt; getManifestWithHttpInfo(&#39; dXJuOmFkc2sub2J ...&#39;,NULL)\ n

urn是正确的并且也正确编码,auth-token的范围是可查看的:read&#39;。

我不知道在哪里搜索,我会感激任何帮助。

修改1:

$twoLeggedAuth->setScopes( [ 'data:read' ] );
$twoLeggedAuth->fetchToken();
$objApiInstance = new Autodesk\Forge\Client\Api\ObjectsApi( $twoLeggedAuth );
$correctObject = "";
$base64Urn = rtrim( strtr( base64_encode( $requestedURN ), '+/', '-_' ), '=' );
try{
    $bucketobjects = $objApiInstance->getObjects($bucket_key);
    foreach ($bucketobjects->getItems() as $key => $bucket_object){
        if($bucket_object->getObjectId() === $requestedURN){
            $correctObject = rtrim( strtr( base64_encode( $bucket_object->getObjectId() ), '+/', '-_' ), '=' );
        }
    }
}catch (Exception $e){
    $erg['failure'] = 'Exception when calling ObjectsApi->getObjects: ' . $e->getMessage();
}

$totranslate = true;
############ TRANSLATION-JOB
if($totranslate){
    $twoLeggedAuth->setScopes( [ 'data:read', 'data:write', 'data:create' ] );
    $twoLeggedAuth->fetchToken();
    $apiInstance = new Autodesk\Forge\Client\Api\DerivativesApi( $twoLeggedAuth );
    $jobInput = array(
        'urn' => $correctObject
    );
    $jobPayloadInput = new Autodesk\Forge\Client\Model\JobPayloadInput( $jobInput );
    $jobOutputItem = array(
        'type' => 'svf',
        'views' => array('3d', '2d')
    );
    $jobPayloadItem = new Autodesk\Forge\Client\Model\JobPayloadItem( $jobOutputItem );
    $jobOutput = [
        'formats' => array( $jobPayloadItem )
    ];
    $jobPayloadOutput = new Autodesk\Forge\Client\Model\JobPayloadOutput( $jobOutput );
    $job = new \Autodesk\Forge\Client\Model\JobPayload();
    $job->setInput( $jobPayloadInput );
    $job->setOutput( $jobPayloadOutput );
    $x_ads_force = true;
    try {
        $result = $apiInstance->translate( $job, $x_ads_force );
        $erg['success'] = 'Success! ';
    } catch( Exception $e ) {
        $erg['failure'] = 'Exception when calling DerivativesApi->translate: ' . $e->getMessage();
    }
}
$twoLeggedAuth->setScopes( [ 'data:read' ] );
$twoLeggedAuth->fetchToken();

$apiInstance = new Autodesk\Forge\Client\Api\DerivativesApi( $twoLeggedAuth );
try {
    $result = $apiInstance->getManifest( $correctObject, null );
    $erg['translationstatus'] = 'Translation Status: ' . $result['status'];
    $erg['translationprogress'] = "\t\nTranslation Progress: " . $result['progress'];
} catch( Exception $e ) {
    $erg['failure'] = 'Exception when calling DerivativesApi->getManifest: ' . $e->getMessage();
}

1 个答案:

答案 0 :(得分:2)

感谢您提供有用的提示,我找到了解决方案。

错误似乎是一个错误,因为ManifestChildren.role的新角色是在没有在模型中声明的情况下定义的。

PROPERTYDB - &gt; Autodesk.CloudPlatform.PropertyDatabase(例如,这是一个缺少的&#39;角色&#39;)

作为解决方法(对我有用)只需设置参数&#34; accept_encoding&#34; getManifest()到&#39; gzip&#39;:

$result = $apiInstance->getManifest( $correctObject, 'gzip' );

现在一切正常。

查看here了解更多信息。