Data Management API:ACC へのファイル アップロードの注意点

Autodesk Construction Cloud logo with file upload icon and supported file types including RVT, DWG, NWD, and PDF.

Data Management API を使って Fusion Team(含む 旧 BIM 360 Team・A360 Personal)や Autodesk Construction Cloud(Autodesk Docs、旧 BIM 360 Docs)などのオートデスクのストレージ サービスにファイルをアップロードを把握する際、公式ドキュメントの How-to Guide に記載されている Upload a File を参考にされると思います。

同ドキュメントに記載されている手順は、Fusion Team と Autodesk Construction Cloud で共通しています。ただし、Step 7: Create the first version of the uploaded fileStep 8: Update the version of a file で紹介されている cURL 使用のリクエスト ボディの JSON ペイロード内容には注意が必要です。

Step 7 の cURL 呼び出し例の場合:

curl -X POST -H "Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT" -H "Content-Type: application/vnd.api+json" -H "Accept: application/vnd.api+json" -d '{
    "jsonapi": {
        "version": "1.0"
    },
    "data": {
        "type": "items",
        "attributes": {
            "displayName": "myfile.jpg",
            "extension": {
                "type": "items:autodesk.core:File",
                "version": "1.0"
            }
        },
        "relationships": {
            "tip": {
                "data": {
                    "type": "versions",
                    "id": "1"
                }
            },
            "parent": {
                "data": {
                    "type": "folders",
                    "id": "urn:adsk.wipprod:fs.folder:co.mgS-lb-BThaTdHnhiN_mbA"
                }
            }
        }
    },
    "included": [
        {
            "type": "versions",
            "id": "1",
            "attributes": {
                "name": "myfile.jpg",
                "extension": {
                    "type": "versions:autodesk.core:File",
                    "version": "1.0"
                }
            },
            "relationships": {
                "storage": {
                    "data": {
                        "type": "objects",
                        "id": "urn:adsk.objects:os.object:wip.dm.prod/2a6d61f2-49df-4d7b-9aed-439586d61df7.jpg"
                    }
                }
            }
        }
    ]
}' "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6d2lwMWZxYWUyOWNlZGY4I0QyMDE2MDQxODM5NDM2NzM/items"

このため、 Upload a File 記載の JSON ペイロード内容の Hub ID、Folder ID、Object ID 等のみを変更して、そのまま Autodesk Construction Cloud にアップロードしたファイルにバージョンを与えようとすると、400 BAD_INPUT エラーでバージョン登録に失敗してしまいます。

Autodesk Construction Cloud へのバージョン登録には、autodesk.bim360:File を指定するようにしてください。

最初のバージョン登録(Step 7)時のリクエスト ボディの JSON ペイロード例:

{
    "jsonapi": {
        "version": "1.0"
    },
    "data": {
        "type": "items",
        "attributes": {
            "displayName": "result.pdf",
            "extension": {
                "type": "items:autodesk.bim360:File",
                "version": "1.0"
            }
        },
        "relationships": {
            "tip": {
                "data": {
                    "type": "versions",
                    "id": "1"
                }
            },
            "parent": {
                "data": {
                    "type": "folders",
                    "id": "urn:adsk.wipprod:fs.folder:co.FtKfsRS2Re6g0keqduq8tw"
                }
            }
        }
    },
    "included": [
        {
            "type": "versions",
            "id": "1",
            "attributes": {
                "name": "result.pdf",
                "extension": {
                    "type": "versions:autodesk.bim360:File",
                    "version": "1.0"
                }
            },
            "relationships": {
                "storage": {
                    "data": {
                        "type": "objects",
                        "id": "urn:adsk.objects:os.object:wip.dm.prod/c6b4e59d-8315-451f-be83-afa751e8525b.pdf"
                    }
                }
            }
        }
    ]
}

By Toshiaki Isezaki

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading