Download a f3 file through the Autodesk Data management api

62 views Asked by At

I have the following python function to try and prepare a download for a fusion created project. Getting the downloadFormats for this file will yield [{'fileType': 'f3z'}] as the available formats for it. But using the following function

def create_download(access_token, project_id, version_id, format_type):
    url = f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/downloads"
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Content-Type": "application/vnd.api+json",
    }
    data = {
        "jsonapi": {"version": "1.0"},
        "data": {
            "type": "downloads",
            "attributes": {
                "format": {
                    "fileType": format_type,
                },
            },
            "relationships": {
                "source": {
                    "data": {
                        "type": "versions",
                        "id": version_id,
                    }
                }
            },
        },
    }

    response = requests.post(url, headers=headers, json=data)
    response.raise_for_status()
    res = response.json()
    return res

Will give the following body back: {'jsonapi': {'version': '1.0'}, 'errors': [{'id': '6c5e1628-3c96-45e3-9af5-6b316f87f823', 'status': '400', 'detail': 'BadRequest'}]}

I have checked that the project id, version id and access token are all valid.

Using any other value for fileType will return the following body: {'jsonapi': {'version': '1.0'}, 'errors': [{'id': 'b1af1d88-d8b6-4e85-a48d-e6febd52b3a4', 'status': '400', 'code': 'BAD_INPUT', 'title': 'One or more input values in the request were bad', 'detail': "Download fileType 'f3' is not supported."}]}

The file is created through fusion and is a template file to be used in other projects, which is why I would like to automatically copy this file to different folders. I found downloading the file and uploading would probably be the best way to do this.

1

There are 1 answers

2
Adam Nagy On

The message "Download fileType 'f3' is not supported." suggests that somehow the message you send to the endpoint ends up saying "f3" instead of "f3z"

You can double-check that by sending the message to a utility website like https://webhook.site/ and check there the exact message your program sends out.

Also, there is a sample desktop app that is using the same endpoint and it still seems to work fine for me:

enter image description here

Give that a try: https://github.com/adamenagy/a360backup-data.management-csharp

However, please note that f3z is an archive format, uploading it back to Fusion Team will just be considered a zip - I don't think you can do anything with it directly, but you can use Fusion 360 to unwrap it an upload the f3d files it contains and set up the references between them.