Model Derivative API Post Job - 400 Bad Request “Invalid 'design' parameter”

一曲冷凌霜 提交于 2020-05-29 06:36:06

问题


I've uploaded a Revit model to my OSS bucket and trying to translate the file to svf, but I'm getting the following:

400 Bad Request {"diagnostic":"Invalid 'design' parameter."}

I'm new to the Forge API and not sure where a design parameter is required or where it's referring to, so any guidance would be appreciated.

POST https://developer.api.autodesk.com/modelderivative/v2/designdata/job

Headers
Authorization: Bearer {AccessToken}
Content-Type: application/json

Body
{
   "input": {
     "urn": "{MyDesignBase64Urn}",
     "compressedUrn": false,
     "rootFilename": "test-project.rvt"
   },
   "output": {
     "destination": {
       "region": "us"
     },
     "formats": [
       {
         "type": "svf",
         "views": [
           "2d",
           "3d"
         ]
       }
     ]
   }
 }

回答1:


For someone has met similar issue

As we per discussed, the main reason caused this issue is missing the urn: while transforming the uploaded file's objectId into base64URN.

After uploading model file on to Forge OSS bucket via PUT buckets/:bucket_key/objects/:object_name, you will obtain a response like this:

{
    "bucketKey": "mybucket",
    "objectId": "urn:adsk.objects:os.object:mybucket/rac_basic_sample_project.rvt",
    "objectKey": "rac_basic_sample_project.rvt",
    "sha1": "6d0defe9c4f8e36c7786254a3d07f9991dbf8d91",
    "size": 16474112,
    "contentType": "application/octet-stream",
    "location": "https://developer.api.autodesk.com/oss/v2/buckets/mybucket/objects/rac_basic_sample_project.rvt"
}

The URN of the uploaded model will be the objectId in above response, i.e. urn:adsk.objects:os.object:mybucket/rac_basic_sample_project.rvt. Before trigger model translation via API POST job, the objectId must have to encoded by Base64 encoder(e.g. this tool) and it becomes the below:

dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXlidWNrZXQvcmFjX2Jhc2ljX3NhbXBsZV9wcm9qZWN0LnJ2dA==

But there are two invalid symbols, i.e. the two = at the end of the base64 encoded URN. You must have to remove them as below and use this URN which is a URL-safe Base64 (no padding) version to trigger a translation job of the Forge MD API.

dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXlidWNrZXQvcmFjX2Jhc2ljX3NhbXBsZV9wcm9qZWN0LnJ2dA

See this official tutorial for details: https://developer.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer



来源:https://stackoverflow.com/questions/51306559/model-derivative-api-post-job-400-bad-request-invalid-design-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!