4

I am trying to use the autodesk forge viewer tutorial

https://developer.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/

I have successfully uploaded and downloaded a dwg file

on the step where i convert it to svf it never seems to process and fails with

{"input":{"urn":"Safe Base64 encoded value of the output of the upload result"},"output":{"formats":[{"type":"svf","views":["2d","3d"]}]}}
HTTP/1.1 400 Bad Request
Result{"diagnostic":"Failed to trigger translation for this file."}

First question do i need to remove the urn: before Base64 encoding. Second is there any more verbose error result that I can see.

Note I have also tried with a rvt file and tried with "type":"thumbnail" nothing seems to work.

I feel my Encoded URN is incorrect but I am not sure why it would be. On the tutorial page they seem to have a much longer and raw urn not sure if I should be appending something else to it before encoding. they have a version and some other number

from tutorial raw "urn:adsk.a360betadev:fs.file:business.lmvtest.DS5a730QTbf1122d07 51814909a776d191611?version=12"

mine raw
"urn:adsk.objects:os.object:gregbimbucket/XXX"

EDIT: This is what i get back from the upload of a dwg file

HTTP/1.1 200 OK
Result{
"bucketKey" : "gregbimbucket",
"objectId" : "urn:adsk.objects:os.object:gregbimbucket/XXX",
"objectKey" : "XXX",
"sha1" : "xxxx",
"size" : 57544,
"contentType" : "application/octet-stream",
"location" : "https://developer.api.autodesk.com/oss/v2/buckets/gregbimbucket/objects/XXX"
}

This is what i send to convert the file

{"input":{"urn":"dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Z3JlZ2JpbWJ1Y2tldC9YWFg"},"output":{"formats":[{"type":"svf","views":["2d","3d"]}]}}

This is the error I get back

HTTP/1.1 400 Bad Request
Result{"diagnostic":"Failed to trigger translation for this file."}

EDIT 2: SOLUTION It looks like the object_id when uploading a file has to have the file extension and not end in a GUI or random set of characters for it to know what file type it is. So that it can be converted.

"objectId" : "urn:adsk.objects:os.object:gregbimbucket/Floor_sm.dwg", 
Greg Bluntzer
  • 323
  • 1
  • 4
  • 21
  • the urn should be the same you get from other calls on the API, it can contain "urn:something", and the "400" bad request means your input is not good...can you post the exact you're calling? – Augusto Goncalves Jul 12 '16 at 22:59
  • @AugustoGoncalves i updated question with the more info – Greg Bluntzer Jul 13 '16 at 12:58
  • if the JSON is accurate, aren't you missing the extension on the file? You just typed 'XXX'. Also, see step 4 here (https://developer.autodesk.com/en/docs/data/v2/tutorials/upload-file/), we use the content-type to determine how to translate (in future we'll use the file extension, I think) – Augusto Goncalves Jul 13 '16 at 13:03
  • 1
    @AugustoGoncalves thanks I got it working by making the object id be the actual file name. – Greg Bluntzer Jul 13 '16 at 14:05
  • great, good to know! if you have time, please share the answer, will gladly vote it up! :-) – Augusto Goncalves Jul 13 '16 at 14:06

1 Answers1

9

SOLUTION It looks like the object_id when uploading a file has to have the file extension and not end in a GUI or random set of characters for it to know what file type it is.

Greg Bluntzer
  • 323
  • 1
  • 4
  • 21
  • 1
    Thats true: When uploading a file you will receive the URN. But the important is THE requested URL within the PUT: When your bucket is named "test" and you want the filename to be "works.ipt" then this has to be the url https://developer.api.autodesk.com/oss/v2/buckets/test/objects/works.ipt' – Patrick Sep 30 '16 at 05:39
  • I had this same problem, and this solution worked, thanks! I misinterpreted a URL being created with MY_OBJECT_NAME as meaning that was the filename before the extension. Added the extension and worked. I was following the instructions here, specifically under the "Upload File to your bucket" section https://autodesk-forge.github.io/?GettingStarted – Jeremy Zerr Mar 18 '18 at 20:08