Hi,
I have tried sending a JSON string e.g.
[{ "fields": { "TITLE": "Ultrabright Flashlight (Red)", "USE_AUTO_DESCRIPTION": "false", "ITEM_CATEGORY": 101 } }]
Where the fields TITLE and ITEM_CATEGORY are mandatory.
And I get back the following error:
{ "errorCode": "GEN_ILLEGAL_INPUT_VALUE", "message": "At least one of the input values was set to an illegal value.", "params": null, "url": null }
I have tried many variations of the above JSON string with the same above error.
Can someone please provide me an example for creating an item in a workspace using REST?
wangdu
Solved! Go to Solution.
Solved by Redmond.D. Go to Solution.
"fields" is a string to string map, so everything has to be quoted. So the ITEM_CATEGORY value should be "101" even if the field is defined as an integer.
If ITEM_CATEGORY is a picklist, then you need to use "picklistFields" instead of "fields".
If you are stuck on the format, a good technique is to create the item manually then view the JSON version of the Item by calling "/api/v2/workspaces/{workspaceId}/items/{itemId}"
NOTE: ItemId is sometimes called "dmsId" in scripts and end-user URLs.
Lastly, I don't recommend using strings to create the JSON. I prefer to create an Object and use a JSON library to serialize/deserialize.
I was trying out direct json string since I was unable to properly execute using json serialize/deserialize. I wanted to see some json string that actually gets executed successfully.
As of now, I have been able to successfully create/update item in a simpler workspace (fields without picklists fields). But I still have trouble creating item with linked-picklist field with SELECTION_REQUIRED type (see below).
My question referring to the mandatory picklistfields is: Does an id suffice or should it require all the values (id, displayName, itemUrl)?
[{ "fields": { "TITLE": "hello" }, "picklistFields": { "ITEM_CATEGORY": [{ "id": 101, "itemUrl": "https://xxxxxx.autodeskplm360.net/api/v2/workspaces/12/items/101" }] } }]
The above request still fails with the same error mentioned in the previous post.
Regards,
Wangdu
I recommeding calling /api/v2/workspaces/{workspaceId}/item-fields/{fieldDefinitionId}/values to get the list of valid selections. Once you find the entry you want, use the entire PicklistValue when updating the item.
I'm curious as to what your serialization problems are. I might be able to help.
Hello again,
I have tried your suggestion (got the entire possible values) and used one of them (entire picklistfields value) with same error.
I have tried also using .net object and then JSON serialize with the same output as the example and of course the same error message.
When I request for an item at /api/v2/workspaces/{workspaceid}/items/{itemid}, i get the following result. (This item was created through web interface filling up only the two (TITLE and ITEM_CATEGORY) mandatory fields)
{ "id" : 1377, "rootId" : 1377, "version" : 1, "revision" : null, "workspaceId" : 8, "url" : "https://xxxxx.autodeskplm360.net/api/v2/workspaces/8/items/1377", "itemDescriptor" : " - ", "deleted" : false, "isWorkingVersion" : true, "isLatestVersion" : true, "fields" : { "NUMBER" : null, "TITLE" : "test test test", "USE_AUTO_DESCRIPTION" : "true", "DESCRIPTION" : "", "UNIT_OF_MEASURE" : null, "COMMENTS" : null, "DIM_VALUE_1" : null, "DIM_VALUE_2" : null, "DIM_VALUE_3" : null, "DIM_VALUE_4" : null, "DIM_VALUE_5" : null, "DIM_VALUE_6" : null, "BILD" : null, "CAD_FILE_NAME" : null }, "picklistFields" : { "ITEM_CATEGORY" : [ { "id" : 101, "displayName" : "10 - Hauptbaugruppe (Produkt)", "itemUrl" : "https://xxxxxx.autodeskplm360.net/api/v2/workspaces/12/items/101" } ], "LEVEL_1" : null, "LEVEL_2" : null, "LEVEL_3" : null, "CLASS_NUMBER" : null, "CLASS_DESCRIPTION" : null, "DIM_TYPE_1" : null, "DIM_UNIT_1" : null, "DIM_SEP_1" : null, "DIM_TYPE_2" : null, "DIM_UNIT_2" : null, "DIM_SEP_2" : null, "DIM_TYPE_3" : null, "DIM_UNIT_3" : null, "DIM_SEP_3" : null, "DIM_TYPE_4" : null, "DIM_UNIT_4" : null, "DIM_SEP_4" : null, "DIM_TYPE_5" : null, "DIM_UNIT_5" : null, "DIM_SEP_5" : null, "DIM_TYPE_6" : null, "DIM_UNIT_6" : null, "DIM_SEP_6" : null, "LINKED_CLASS" : [ { "id" : -999, "displayName" : null, "itemUrl" : "https://xxxxxx.autodeskplm360.net/api/v2/workspaces/50/items/-999" } ] } }
The workspace in question is "Items and BOMs" and created by another colleague of mine. Do you think this workspace can't be filled with arbitrary items? (But I have been able to create item through web interface with just the TITLE and a value from the Dropdown list!) 😞
Regards,
Wangdu
I can reproduce the issue with my "Items and BOMs" workspace. I'll investigate further and let you know what I find.
Also, it's on my to-do list to provide information on which fields failed during a GEN_ILLEGAL_INPUT_VALUE failure.
FYI, we have some samples on github about PLM360 REST API :
https://github.com/ADN-DevTech/PLM360-API-Samples
The 9.2 version of PLM 360 was just deployed this weekend, and it contains some REST fixes. You should now be able to add and update items by passing in a valid picklist value.
Unforunately, there is still an open issue. If you try to pass in null or omit a filtered picklist field, then you still get the GEN_ILLEGAL_INPUT_VALUE error. We are currently working to address this issue.
I have tried adding an item with a fixed picklist and it worked.
The one for Items and Boms has several filtered picklists and I looked for them after going through your reply. Definitely, the request ends up with GEN_ILLEGAL_INPUT_VALUE error for omission as well as null values. FYI, I tried specifying each one a possible picklist value {id,displayname and itemurl} and it also ended up with GEN_ILLEGAL_INPUT_VALUE error.
Thanks for your support.
I recommend avoiding the Items and BOMs workspace until all the filtered picklist issues have been addressed. That workspace has a painful amount of filtered picklists.
Here are some of the open issues that could be causing your error: