# Get Inventory Roles via SDK

**URL:** <https://community.cumulocity.com/t/get-inventory-roles-via-sdk/4722>\
**Category:** Forum\
**Tags:** cumulocity\
**Created:** [May 30, 2022, 9:09am UTC](https://community.cumulocity.com/t/get-inventory-roles-via-sdk/4722 "2022-05-30T09:09:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melanie\_Monnereau](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@Melanie\_Monnereau](https://community.cumulocity.com/u/Melanie_Monnereau)\
**Post date:** [May 30, 2022, 9:09am UTC](https://community.cumulocity.com/t/get-inventory-roles-via-sdk/4722/1 "2022-05-30T09:09:51Z")

</div>

Using the Microservice SDK 10.9 I would like to retrieve the inventory roles for a user X.

Is this at all possible using the UserAPI?

Via REST, the call would look like {{url}}/user/{{tenantId}}/users/{{userID}}/roles/inventory

thanks

---

<div class="post-metadata">

**Author:** ![Kai\_Sieben](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/kai_sieben/32/5541_2.png) [@Kai\_Sieben](https://community.cumulocity.com/u/Kai_Sieben)\
**Post date:** [May 30, 2022, 9:36am UTC](https://community.cumulocity.com/t/get-inventory-roles-via-sdk/4722/2 "2022-05-30T09:36:42Z")

</div>

The UserApi does not implement this API call.

You would need to implement it yourself, e.g. using the “RestConnector” class and leverage the already existing Rest-Representation class “InventoryAssignmentCollectionRepresentation”:

```auto
import com.cumulocity.rest.representation.CumulocityMediaType;
import com.cumulocity.rest.representation.user.InventoryAssignmentCollectionRepresentation;
import com.cumulocity.sdk.client.RestConnector;

[...]

@Autowired
private RestConnector restConnector;

[...]
InventoryAssignmentCollectionRepresentation inventoryRoleAssignment = restConnector
	.get("/user/" + tenantId + "/users/" + userID + "/roles/inventory",
		CumulocityMediaType.APPLICATION_JSON_TYPE,
		InventoryAssignmentCollectionRepresentation.class);

```

(\*) code is not tested

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [August 28, 2022, 9:37am UTC](https://community.cumulocity.com/t/get-inventory-roles-via-sdk/4722/3 "2022-08-28T09:37:17Z")

</div>

Closed on August 28, 2022, 9:37am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
