Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
160 views
in Technique[技术] by (71.8m points)

Issue with getManifest (forge-php-client)

It seems there is an issue with the DerivativesApi.getManifest method or with the ManifestChildren.setRole method.

When I call "$apiInstance->getManifest", I get the following error message:

"Exception when calling DerivativesApi->getManifest: Invalid value for 'role', must be one of '2d', '3d', 'graphics', 'manifest', 'thumbnail'"

Here's the Stacktrace:

1 *ObjectSerializer.php(236): AutodeskForgeClientObjectSerializer::deserialize(Object(stdClass), '\Autodesk\Forge...', NULL)

2 *ObjectSerializer.php(291): AutodeskForgeClientObjectSerializer::deserialize(Array, '\Autodesk\Forge...', NULL)

3 *ObjectSerializer.php(236): AutodeskForgeClientObjectSerializer::deserialize(Object(stdClass), '\Autodesk\Forge...', NULL)

4 *ObjectSerializer.php(291): AutodeskForgeClientObjectSerializer::deserialize(Array, '\Autodesk\Forge...', NULL)

5 *DerivativesApi.php(403): AutodeskForgeClientObjectSerializer::deserialize(Object(stdClass), '\Autodesk\Forge...', Array)

6 *DerivativesApi.php(336): AutodeskForgeClientApiDerivativesApi->getManifestWithHttpInfo('dXJuOmFkc2sub2J...', NULL)

The urn is correct and also correctly encoded, the scope of the auth-token is 'viewables:read'.

I don't know where to search, I'd appreciate any kind of help.

Edit 1:

$twoLeggedAuth->setScopes( [ 'data:read' ] );
$twoLeggedAuth->fetchToken();
$objApiInstance = new AutodeskForgeClientApiObjectsApi( $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 AutodeskForgeClientApiDerivativesApi( $twoLeggedAuth );
    $jobInput = array(
        'urn' => $correctObject
    );
    $jobPayloadInput = new AutodeskForgeClientModelJobPayloadInput( $jobInput );
    $jobOutputItem = array(
        'type' => 'svf',
        'views' => array('3d', '2d')
    );
    $jobPayloadItem = new AutodeskForgeClientModelJobPayloadItem( $jobOutputItem );
    $jobOutput = [
        'formats' => array( $jobPayloadItem )
    ];
    $jobPayloadOutput = new AutodeskForgeClientModelJobPayloadOutput( $jobOutput );
    $job = new AutodeskForgeClientModelJobPayload();
    $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 AutodeskForgeClientApiDerivativesApi( $twoLeggedAuth );
try {
    $result = $apiInstance->getManifest( $correctObject, null );
    $erg['translationstatus'] = 'Translation Status: ' . $result['status'];
    $erg['translationprogress'] = "	
Translation Progress: " . $result['progress'];
} catch( Exception $e ) {
    $erg['failure'] = 'Exception when calling DerivativesApi->getManifest: ' . $e->getMessage();
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Thank you for your useful hints, I found a solution.

The error seems to be a bug that occurs because new roles for ManifestChildren.role were defined without beeing declared within the model.

PROPERTYDB -> Autodesk.CloudPlatform.PropertyDatabase (e.g. this is one missing 'role')

As workaround (that worked for me) just set the parameter "accept_encoding" of getManifest() to 'gzip':

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

Everything works fine now.

Look here for further information.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...