v3 API - POST Create workspace item?

v3 API - POST Create workspace item?

Anonymous
Not applicable
912 Views
2 Replies
Message 1 of 3

v3 API - POST Create workspace item?

Anonymous
Not applicable

I see the recently retired v1 API had a POST to create workspace items using metaFields: https://help.autodesk.com/view/PLM/ENU/?guid=PLM_360_REST_APIv1_Resource_Endpoints_Workspace_Items_w...

 

The v3 documentation for /workspaces/<id>/items does not appear to include anything similar, however an empty-body POST to the endpoint suggests that it is probably possible using section fields:

{
    "statusCode": 400,
    "errors": [
        "BAD_REQUEST"
    ],
    "message": "Invalid input. No sections specified for create"
}
 

Wondering if there is other documentation I missed or if anyone knows how this is done in the v3 API?

0 Likes
Accepted solutions (1)
913 Views
2 Replies
Replies (2)
Message 2 of 3

giliar.defriesperez
Autodesk
Autodesk
Accepted solution

Hi @Anonymous ,

In general terms, you need to perform a GET the following way to get the metada about the workspace and the sections in the item details form:

curl --location --request GET 'https://tenant_name.autodeskplm.com/api/v3/workspaces/:wsId:/sections' \
--header 'Authorization: Bearer BEARER_TOKEN' \
 
This will give you a payload like this (just a sample):
[
  {
    "name": "Section1",
    "description": "",
    "type": "FIELDCONTAINER",
    "displayOrder": 1,
    "collapsed": false,
    "sectionType": "FIELDCONTAINER",
    "fields": [
      {
        "link": "/api/v3/workspaces/64/views/1/fields/FPL_ITEMS_AND_BOMS",
        "urn": "urn:adsk.plm:tenant.workspace.view.field:TENANT_NAME.64.1.FPL_ITEMS_AND_BOMS",
        "title": "FPL Items And BOMs ",
        "deleted": false,
        "type": "FIELD"
      },
      {
        "link": "/api/v3/workspaces/64/views/1/fields/FPL_ITEMS_AND_BOMS_DESC",
        "urn": "urn:adsk.plm:tenant.workspace.view.field:TENANT_NAME.64.1.FPL_ITEMS_AND_BOMS_DESC",
        "title": "FPL Items And BOMs Desc",
        "deleted": false,
        "type": "FIELD"
      },
      {
        "link": "/api/v3/workspaces/64/views/1/fields/FLOAT",
        "urn": "urn:adsk.plm:tenant.workspace.view.field:TENANT_NAME.64.1.FLOAT",
        "title": "Float",
        "deleted": false,
        "type": "FIELD"
      },
      {
        "link": "/api/v3/workspaces/64/views/1/fields/BOM_UOM",
        "urn": "urn:adsk.plm:tenant.workspace.view.field:TENANT_NAME.64.1.BOM_UOM",
        "title": "BOM UOM",
        "deleted": false,
        "type": "FIELD"
      }
    ],
    "sectionLocked": false,
    "pimSection": false,
    "__self__": "/api/v3/workspaces/64/sections/250",
    "urn": "urn:adsk.plm:tenant.workspace.section:TENANT_NAME.64.250",
    "matrices": [  
    ]
  }
]

I have four fields in this workspace, in a single section.

With this information, you need to structure the payload for a POST the following way:

POST https://TENANT_NAME.autodeskplm.com/api/v3/workspaces/:wsId:/items
Accept: application/json
Authorization: Bearer BEARER_TOKEN

And, with that, you can pass the following body (again, just a sample):

{
  "sections": [
    {
      "link": "/api/v3/workspaces/64/sections/250",
      "fields": [
        {
          "__self__": "/api/v3/workspaces/64/views/1/fields/FPL_ITEMS_AND_BOMS",
          "value": {
            "title": "4",
            "link": "4"
          },
          "title": "FPL Items And BOMs "
        },
        {
          "__self__": "/api/v3/workspaces/64/views/1/fields/FPL_ITEMS_AND_BOMS_DESC",
          "value": {
            "link": "/api/v3/workspaces/57/items/7830",
            "urn": "urn:adsk.plm:tenant.workspace.item:TENANT_NAME.57.7830",
            "title": "NU000133 - Manual Creation of Item to be revised1",
            "deleted": false,
            "version": "[REV:sA]"
          },
          "title": "FPL Items And BOMs Desc"
        },
        {
          "__self__": "/api/v3/workspaces/64/views/1/fields/FLOAT",
          "value": "123",
          "title": "Float"
        },
        {
          "__self__": "/api/v3/workspaces/64/views/1/fields/BOM_UOM",
          "value": {
            "link": "/api/v3/lookups/BOM-UOM/options/1",
            "title": "Each"
          },
          "title": "BOM UOM"
        }
      ]
    }
  ]
}

While it might look a bit daunting, the payload is structured in a way that you pass a list of fields inside the section(s) with their values. If you need to know about validators and other info for the fields, you can do the following before building the payload:

GET https://TENANT_NAME.autodeskplm.com/api/v3/workspaces/:wsView:/views/1/fields

 

These are just general pointers, but I hope you can get the idea. Some people find it easier to open the Network panel in Chrome/Firefox, and when saving the information, look at the network traffic for requests. It's basically the same you'd be doing in an external app.

 

Hope this helps.

 

- Giliar

 


Giliar de Fries Perez
Sr. Product Owner
Fusion 360® Manage
Autodesk Canada Co.
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi @giliar.defriesperez - thanks for the response. Definitely sorted me out!

 

For anyone else following in my footsteps you also need to add the section ID to get the type of content shown in the sample GET provided by Giliar. i.e.:

https://tenant_name.autodeskplm.com/api/v3/workspaces/:wsId:/sections/:secID:

The tip to use the networking debugger built into the browser was particularly helpful. Also worth noting that you can omit any sections from the create that aren't mandatory in your workspace to clean things up.