Autodesk Platform Services 创建文件首个版本时URN格式错误求助
关于Autodesk Forge API上传文件时URN格式错误的排查求助
我遇到的问题和某Stack Overflow帖子类似,但其中的解决方案无法解决我的问题。按照官方分步说明操作,前几步均正常,直到执行第7步(创建已上传文件的首个版本)时出现问题。不确定是否必须执行此步骤才能完成上传,但由于文件未出现在目标文件夹中,我认为此步骤是必要的。
使用的请求体(C#代码)
string requestBody = @" { ""jsonapi"": { ""version"": ""1.0"" }, ""data"": { ""type"": ""items"", ""attributes"": { ""displayName"": """ + fileName + @""", ""extension"": { ""type"": ""items:autodesk.bim360:File"", ""version"": ""1.0"" } }, ""relationships"": { ""tip"": { ""data"": { ""type"": ""versions"", ""id"": ""1"" } }, ""parent"": { ""data"": { ""type"": ""folders"", ""id"": """ + folderId + @""" } } } }, ""included"": [ { ""type"": ""versions"", ""id"": ""1"", ""attributes"": { ""name"": """ + fileName + @""", ""extension"": { ""type"": ""versions:autodesk.bim360:File"", ""version"": ""1.0"" } }, ""relationships"": { ""storage"": { ""data"": { ""type"": ""objects"", ""id"": """ + objectId + @""" } } } } ] }";
解析后的请求体
{ "jsonapi": { "version": "1.0" }, "data": { "type": "items", "attributes": { "displayName": "ACCUploadTest8.log", "extension": { "type": "items:autodesk.bim360:File", "version": "1.0" } }, "relationships": { "tip": { "data": { "type": "versions", "id": "1" } }, "parent": { "data": { "type": "folders", "id": "urn:Aadsk.wipprod:Afs.folder:Aco.CdqHiUXsTUaXBnE6Iwxb8g" } } } }, "included": [ { "type": "versions", "id": "1", "attributes": { "name": "ACCUploadTest8.log", "extension": { "type": "versions:autodesk.bim360:File", "version": "1.0" } }, "relationships": { "storage": { "data": { "type": "objects", "id": "urn:adsk.objects:os.object:wip.dm.prod/b1333e7c-39ae-41e4-a94e-e0c3c3c87c58.log" } } } } ] }
收到的错误响应
{"jsonapi":{"version":"1.0"},"errors":[{"id":"129d054e-6da7-4bbc-a04d-e220e7043466","status":"400","code":"BAD_INPUT","title":"One or more input values in the request were bad","detail":"Urn is not in the proper format."}]}
排查与解决办法
错误原因
报错指向URN格式不正确,重点检查两个URN:
- 文件夹ID的URN:当前使用的
urn:Aadsk.wipprod:Afs.folder:Aco.CdqHiUXsTUaXBnE6Iwxb8g开头为大写Aadsk,而Autodesk Forge API的URN规范要求开头为小写adsk,这是格式错误的核心原因。 - 存储对象的URN:格式
urn:adsk.objects:os.object:wip.dm.prod/xxx.log是正确的,但需确认该objectId是直接从获取上传位置的API返回的原始值,未被额外修改。
解决步骤
- 将文件夹ID的URN开头的
Aadsk改为小写adsk,修正后为:urn:adsk.wipprod:Afs.folder:Aco.CdqHiUXsTUaXBnE6Iwxb8g - 确认
objectId直接使用获取存储位置接口返回的id字段值,不要进行拼接或修改 - 重新发起创建文件版本的请求
补充说明
创建文件首个版本的步骤是必须的:上传文件到S3只是将文件放到临时存储,只有通过该API才能将文件关联到ACC/BIM360的项目文件夹中,使其在界面上可见。
内容的提问来源于stack exchange,提问作者kdsdot
相关产品推荐
相关产品推荐

