Expand my Community achievements bar.

Unable to find users , user roles , company information through Mangento Rest API in postman

Avatar

Level 1

Hi , 

I am using Magento Storefront admin Panel (Adobe Commerce) and trying to use the Rest APIs in postman.

 

Yash5_4-1731663728955.png

 

 

I have generated the access token and it is working properly with other APIs

I want to find the user and user related roles through the API , these are the following endpoints which i found:

 

{{baseUrl}}/V1/company/role/:roleId/users

{{baseUrl}}/V1/company/role/:roleId

{{baseUrl}}/V1/company/?searchCriteria[filterGroups][0][filters][0][field]=<string>

 

whenever i try to access these endpoints using the token that is required for authorization it is giving 

{
    "message": "Request does not match any route."
}
 
Please guide me if there's an API endpoint for company , users , roles in magneto and how to access it  to get the desired result
2 Replies

Avatar

Level 5

Hi @Yash5 
I am not a Magento expert, but I remember I have seen endpoints like /rest/{store}/V1/company or /rest/V1/products. Maybe you need to prefix your URLs with /rest/, in case {{baseUrl}} does not already have it. Or consider also possibility that these company APIs are not ootb and you may need to develop them for your project. Just smth to think about.

Avatar

Level 2

To retrieve user and user-related role information in Magento (Adobe Commerce), it's important to ensure that you're using the correct API endpoints and structure, especially since Magento's API can have variations based on versions and configurations.

 

Based on your description, the error `Request does not match any route.` typically means that the endpoint you're calling is either incorrect or not available in your current Magento configuration.

 

### Key Points to Check:

  1. API Version and Base URL: Make sure you're using the correct API version and base URL for the environment. You should be using the `V1` endpoint in a typical Magento instance, as you're doing, but ensure that the `{{baseUrl}}` is correct for your setup.
  2. Authentication: Verify that the generated access token you're using has the required permissions to access the user and role-related endpoints.
  3. Magento Version: Some of the company and user role-related APIs you mentioned (`company/role`) might be part of Magento's Commerce (Enterprise) version, which may have additional modules like *B2B* or *Company Account*. If you're on a Community Edition, those endpoints may not be available.

 

### API Endpoints for User and Role Management:

If you want to retrieve user and role-related data, you need to ensure you're accessing the correct endpoints and using valid request formats. Here's how you can retrieve roles and associated users:

 

#### 1. List All Roles:

To get a list of all roles:

```http

GET {{baseUrl}}/V1/roles

```

 

This endpoint will return all roles in the system. Make sure you have an admin role with permissions to access this data.

 

#### 2. Get Role Details:

To get a specific role's details by its `roleId`:

```http

GET {{baseUrl}}/V1/roles/:roleId

```

Replace `:roleId` with the actual role ID you want to query.

 

#### 3. Get Users Assigned to a Role:

To get the users assigned to a specific role, you can use this endpoint:

```http

GET {{baseUrl}}/V1/roles/:roleId/users

```

Replace `:roleId` with the actual role ID you want to query.

 

#### 4. Get Users:

To retrieve all users (for Magento Commerce):

```http

GET {{baseUrl}}/V1/users

```

 

If you're looking to retrieve users based on specific criteria (such as searching for users), you might need to pass search criteria in the query string or body.

 

#### 5. Search for Users with Filters:

To search users with specific filters, use a query like this:

```http

GET {{baseUrl}}/V1/users?searchCriteria[filterGroups][0][filters][0][field]=email&searchCriteria[filterGroups][0][filters][0][value]=example@example.com

```

This searches users based on specific fields (like email).

 

---

 

### Additional Considerations:

 

- Permissions: Ensure that the access token you're using has the necessary permissions to query these endpoints. You may need to assign specific roles or permissions to the API user.

- API Access Configuration: If you're using Magento Commerce's B2B features, you might need to ensure that the `company` module is properly enabled and that you're calling endpoints specific to that feature.

- Search Criteria: The `searchCriteria` parameter is commonly used for filtering data in Magento API calls. Make sure the filter is correctly structured (e.g., `field`, `value`, `conditionType`).

 

### Example Correct Request:

If you're trying to get all users assigned to a specific role, the request would look like this:

 

```http

GET {{baseUrl}}/V1/roles/3/users

```

Where `3` is the `roleId` of the role you're interested in.

 

If you receive the error `Request does not match any route.`, it's worth verifying:

- Whether the API is enabled and properly configured in your Magento instance.

- Whether the route you're trying to access exists in your current Magento version and edition.

- If you're running a version of Magento that supports the company or role-based API (primarily in Magento Commerce/Enterprise).

 

I hope this helps guide you to the correct API endpoints. Let me know if you have any questions or issues!