You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ACC API PATCH请求报400错误:如何正确修改文件属性?

问题描述

我尝试使用Workato调用Autodesk Construction Cloud (ACC) API发送PATCH请求,修改文件/文档的属性(例如displayName),但持续遇到400错误:"One or more input values in the request were bad","detail":"Request input is invalid for this operation."。已参照ACC API官方文档操作,但无论如何都会触发该错误。我在Postman中执行的PATCH请求也出现同样问题,对应的curl请求示例如下:

curl -v
'https://developer.api.autodesk.com/data/v1/projects/:project_id/items/:item_id'  
-X 'PATCH'  
-H 'Authorization: Bearer AuIPTf4KYLTYGVnOHQ0cuolwCW2a'  
-H 'Content-Type: application/vnd.api+json'  
-d '{
        "jsonapi": {
          "version": "1.0"
        },
        "data": {
          "type": "items",
          "id": ":item_id",
          "attributes": {
            "displayName": "new name for drawing.dwg"
          }
        }
      }'

请问正确的PATCH请求方式是什么?


正确的PATCH请求方式

ACC API修改文件item的属性时,必须在请求体中包含relationships.storage字段,指向该item当前关联的storage资源,不能仅修改attributes字段。这是因为ACC的item与storage资源强绑定,缺少该关联会触发400参数错误。

修正后的curl示例

curl -v 'https://developer.api.autodesk.com/data/v1/projects/:project_id/items/:item_id' \
-X PATCH \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
  "jsonapi": {
    "version": "1.0"
  },
  "data": {
    "type": "items",
    "id": ":item_id",
    "attributes": {
      "displayName": "new name for drawing.dwg"
    },
    "relationships": {
      "storage": {
        "data": {
          "type": "objects",
          "id": ":storage_object_id"
        }
      }
    }
  }
}'

关键注意事项

  • 获取storage_object_id:先发送GET请求到/data/v1/projects/:project_id/items/:item_id,在返回的data.relationships.storage.data.id中提取该值。
  • 权限验证:确保access token包含data:write的scope,否则会触发权限错误。
  • 字段格式:type字段必须严格匹配:item的type为items,storage的type为objects,不能写错。
  • 文件名后缀:修改displayName时需保留原文件后缀(如.dwg),否则可能触发格式校验错误。

内容的提问来源于stack exchange,提问作者devathome98

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 02:42:34