使用Data Management API复制项目及版本时遇URN格式错误求助
解决Forge Data API中copyFrom参数的URN格式错误问题
我正尝试通过Forge的Items和Versions接口,自动化将文件的最新版本从一个文件夹结构复制到另一个。但使用URL编码后的URN(例如urn%3Aadsk.wipprod%3Afs.file%3Avf.KKfHjZZ7S3unSVA62YHM7g%3Fversion%3D1)调用接口时,持续收到格式错误提示:
Version接口错误
{ "jsonapi": { "version": "1.0" }, "errors": [ { "id": "395d9751-780f-4d53-8162-e275026e48db", "status": "400", "code": "BAD_INPUT", "title": "One or more input values in the request were bad", "detail": "Request contains malformed Urn for copyFrom parameter." } ] }
Item接口错误
{ "jsonapi": { "version": "1.0" }, "errors": [ { "id": "8563555f-8dad-4ad0-9c6a-f0ff95ccbc60", "status": "400", "code": "BAD_INPUT", "title": "One or more input values in the request were bad", "detail": "Request contains urn%3Aadsk.wipprod%3Afs.file%3Avf.q4ytBrfgRCOJht2n9MKiOg%3Fversion%3D1, which is not a valid URN" } ] }
解决方案
问题出在URN的编码方式上:
- copyFrom参数必须使用未编码的原始URN,不能提前做URL编码。Forge API会自行处理请求中的编码逻辑,提前编码的字符串会被识别为无效格式。
- 正确的URN格式示例:
urn:adsk.wipprod:fs.file:vf.KKfHjZZ7S3unSVA62YHM7g?version=1 - 操作要点:
- 直接使用从Forge API获取的原始版本ID(即未编码的URN)作为copyFrom的值
- 如果发送JSON格式的请求体,直接将原始URN字符串填入参数,无需任何编码处理
- 若使用表单提交,HTTP客户端会自动完成URL编码,同样不需要手动编码URN
内容的提问来源于stack exchange,提问作者Ravi Vaish
相关产品推荐
相关产品推荐

