简体   繁体   中英

Autodesk Forge API - Patch Item Input Error

I am trying to use the PATCH projects/:project_id/items/:item_id endpoint in order to update the "displayName" attribute of an item in BIM360. There is an example on how to do exactly that in the Forge documentation, but for some reason I am getting an 400 error.

Here is my payload:

{
    "jsonapi": {
        "version": "1.0"
    },
    "data": {
        "type": "items",
        "id": "ITEM_URN",
        "attributes": {
            "displayName": "NEW_ITEM_NAME.EXTENSION"
        }
    }
}

Here is the error I get:

{
    "jsonapi": {
        "version": "1.0"
    },
    "errors": [
        {
            "id": "a4c43bbb-9e34-4973-9f9c-58a7e1d7bdb6",
            "status": "400",
            "code": "BAD_INPUT",
            "title": "One or more input values in the request were bad",
            "detail": "Request input is invalid for this operation."
        }
    ]
}

I successfully use the same endpoint in order to change the parent folder for this same item (as described in this post answer: Autodesk Forge; Pragmatically changing file location without new upload ), so the problem must be in the update "displayName" portion. Here the successful payload sample that returns a 200 answer:

{
    "jsonapi": {
        "version": "1.0"
    },
    "data": {
        "type": "items",
        "id": "ITEM_URN",
        "relationships": {
            "parent": {
                "data": {
                    "type": "folders",
                    "id": "DESTINATION_FOLDER_URN"
                }
            }
        }
    }
}

Forge Documentation with example: https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-items-item_id-PATCH/

What am I missing in order to update the "displayName" attribute?

If you want to change the file name, you can change tip version name and title , creating new version is required, but you don't have to upload file again. Please try the API at https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-POST/ :

POST /versions?copyFrom={tip_version_urn}
{
  "jsonapi": {
    "version": "1.0"
  },
  "data": {
    "type": "versions",
    "attributes": {
      "name": "newName"
    }
  }
}

A new tip version will be created with the updated name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM