0

I'm trying to translate an object I've previously uploaded to a Forge bucket, but I'm getting a parameter error. I'm assuming the URN is the issue. I can confirm that the object is uploaded properly, as I have been able to download it from the bucket.

My code is as follows:

I use the getObjectDetails call to get the object URN as the object ID:

static getObjectUrn (oAuth2TwoLegged, objectName, callback) {
    ObjectsApi.getObjectDetails(bucketKey, objectName, {}, oAuth2TwoLegged, oAuth2TwoLegged.getCredentials()).then((resp) => {
        callback(null, resp.body.objectId);
    }, callback);
}

I get back something like: urn:adsk.objects:os.object:configtest2/f8d215f7-9ff0-474a-87b9-632ca745b39eresult.zip

My request body looks like this:

let data = urn;
var buf = new Buffer(data, 'base64'); 
var plain_buf = buf.toString(); 
console.log(plain_buf); 

const resolvedTemplate = {
                        'input': {
                            "urn": plain_buf,
                            "compressedUrn": true,
                            "rootFilename": self.rootFilename
                        },
                        'output': {
                            "destination": {
                              "region": "us"
                            },
                            "formats": [
                              {
                                "type": "svf",
                                "views": [
                                  "3d"
                                ]
                              }
                            ]
                          },
                    };

I've tried a couple different variations of the urn before and after encoding it, to no avail. My root file name is PlaysetGA.iam, although this is a .zip folder, so I've also tried the path inside the folder which is Playset/PlaysetGA.iam.

I've checked out the following page: https://forge.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/ and this question: Model Derivative API Post Job - 400 Bad Request "Invalid 'design' parameter"

This is the response I'm getting: {"diagnostic":"Invalid 'design' parameter."}

Obviously, I'm missing something. Thanks!

Edit: I've updated my .zip folder so my rootfile is in the base file path. This the the root directory:

Root folder

Kate
  • 61
  • 6

2 Answers2

0

Currently the POST job endpoint only supports file names, not file paths, in the rootFilename parameter. If you want to translate a ZIP file, you'll need to make sure that the root filename is available directly in the root of the archive.

Petr Broz
  • 8,891
  • 2
  • 15
  • 24
  • Thanks for the answer! I threw a test .zip in and gave it a try, but I still get the same answer. These are my inputs with the encoding: {"input":{"urn":"���v�(n7���,���r�(�����-��:m�8i��ݾ�Z��]��7k��w�6s�޲�m�*","compressedUrn":true,"rootFilename":"PlaysetGA.iam"},"output":{"destination":{"region":"us"},"formats":[{"type":"svf","views":["3d"]}]}} I'm hoping you might see my error. Do I need to remove 'urn:' before encoding? – Kate Feb 16 '20 at 23:18
  • Hmm, that URN doesn't seem right. The string should only consist of letters, numbers, and `+` and `/` symbols (https://en.wikipedia.org/wiki/Base64). Are you sure you're base64-encoding the original string properly? Try encoding it with this webpage: https://www.base64encode.org. – Petr Broz Feb 17 '20 at 14:07
  • 1
    Thanks for pointing me in the right direction. The settings for the encoding were wrong, and one of the functions had been deprecated. – Kate Feb 17 '20 at 18:21
0

Turns out

var buf = new Buffer.from(unencoded_urn, 'ascii'); 
var plain_buf = buf.toString('base64'); 

was the proper way to encode the URN where the unencoded_urn was retrieved from the ObjectsApi.getObjectDetails function.

Kate
  • 61
  • 6