API Method to Set Categorization Attribute

API Method to Set Categorization Attribute

imckenzieY7CGY
Advocate Advocate
225 Views
3 Replies
Message 1 of 4

API Method to Set Categorization Attribute

imckenzieY7CGY
Advocate
Advocate

Looking for guidance on how to call the Upchain API to set a categorization attribute. 

 

Say I have categoryId: 20 with attribute id: 1807, value type LOV - the list of values includes item indexes 1 thru 18. 

 

For a particular item, which does not have any category information yet, I want to set this attribute to a specific value. 

 

Do I call

/api/bom/v1/part_version/{partVersionId}/category_attribute

to accomplish this, passing the target partVersionId as a header - and do I have to do a POST to set versus a PATCH to change it?

 

What does the body of the request include to accomplish what I want to do? Am I missing any information if I have the output of the following call already: 

/api/category_attribute/v1/20

 

Thanks

0 Likes
226 Views
3 Replies
  • API
Replies (3)
Message 2 of 4

mario_hoblaj
Autodesk
Autodesk

Hi, 

yes, for setting specific attribute LOV value to an item you can call that PATCH endpoint 

/api/bom/v1/part_version/{partVersionId}/category_attribute

 

You need to provide partVersionID as url param and Upc-Selected-Company (ID of your tenant).

In the request body you need to provide:

- attributeID - ID of you category attribute (you can find it by calling GET /api/category_attribute/v1/{categoryId})

- categoryID - ID of the category (you can find it by calling GET/api/category/v1/categories})

- itemID - same ID as for partVersionID 

- valueLov - ID of you LOV category attribute (you can also find it by calling GET /api/category_attribute/v1/{categoryId})

 

Video example attached, please let me know if you have any additional question.

 

Thanks, 

 

Mario Hoblaj

 

0 Likes
Message 3 of 4

imckenzieY7CGY
Advocate
Advocate

Thanks for the reply - just tested this out and it seems to partially work, but I'm seeing slightly different behaviour in the webapp. 

 

When I make the patch call, I get a 200 OK response indicating it went through, but when I view the categories tab as you show in your video, nothing is shown. 

 

If I then click the '+' and go through the category selection, once I add the category and get to the view where I could set the attribute, I see that it is already set. So it seems like a step is missing for my setup.. 

 

My guess is that this is maybe related to our category hierarchy - the attribute I'm trying to set is for a nested category.. So we have category "CompanyName" with subcategory "DivisionName" that then has the LOV attribute I can set. Calling /api/category/v1/categories shows the parent category as id 17, with a 'children' array, which includes category id 20 and then /api/category_attribute/v1/20 returns the attribute I want to set. 

 

Is there some kind of step where I need to set an attribute on the parent category to show the child category?

0 Likes
Message 4 of 4

imckenzieY7CGY
Advocate
Advocate

Update on this - I think I've confirmed my suspicion. The "CompanyName" category has several attributes - one of which is a string which defaults to empty. If I just make a call to set it empty explicitly, the categories now show in the webapp with my previous update to the attribute I actually wanted to target.. 

 

I guess the safer flow would be to check if it has that attribute set already and only write blank if it's not set..? Or is there a better way to do this that I'm missing? It just seems that the child category won't show until I set *something* on the parent category. 

0 Likes