Wix API 2024 – How to add a product to the category using Postman

Table of Contents

In Wix API, you can use Postman to add a product to the category. It makes website organization easy and quick. That is why Beehexa will show you how to do it in this article today. If you want to know how to create a product category, you can read the previous blog: Wix API 2023 – How to create a product category using Postman

Let’s explore this subject a little deeper. If this is your first call in the Postman, you must generate API credentials from the Wix Developers website.

Step 1: Generate API credentials from the Wix Developers’ Website.

Follow the process in Wix API: How to get an access token and refresh the access token? To know how to access Wix API. 

  • After creating an app, remember the access and refresh tokens to send requests in the Postman. 

Step 2: Refresh the access token using Postman. 

Wix’s access token is only valid for 5 minutes, so you need to use the refresh token to request a new access token.

Flowing the steps below for refreshing the access token. 

  • Log in to your Postman and create a new workspace.
  • Create a new POST with this URL:
https://www.wix.com/oauth/access
  • In the body section, enter the code

Payload

{
    "grant_type": "refresh_token",
    "client_id": <APP_ID>,
    "client_secret": <APP_SECRET>,
    "refresh_token": <REFRESH_TOKEN>
}
beehexa refresh the access token
Beehexa – Refresh the access token

Body Params:

NAMETYPEDESCRIPTION
grant_typestringValue must be set to “refresh_token”
client_idstringThe App ID as defined in the Wix Developers Center
client_secretstringThe Secret Key for your app as defined in your Wix Developers Center
refresh_tokenstringThe refresh token issued with the access token
  • Then click SEND

Response:

The Postman will return the new access token and the refresh token in order to request a new access token. 

beehexa access token and refresh token 1
Beehexa – Get the access token and refresh token

Step 3: Add the product to the category using Postman

You must get the product ID first to add the product to the category..

  • Go to the Wix Dashboard
  • Choose “Products”
  • Click on the product you want to add to the category
  • And copy the product ID in the URL

In this case, the product ID = 61ea866c-1564-401d-aa5e-1a2fc1bf28ed

Now, let’s get the category ID because the next call includes that parameter.

There are two ways to get the category ID.

The first way you can copy the ID in the response category of the cataloging command

The second way is to query the category and select the category ID to which you want to add the product.

In this article, I will get it the first way. You can read this blog to know more about that: Wix API 2023 – How to create a product category using Postman

The second way I will show you in the next article.

Now, I have the category ID = 789da22a-23f7-42d9-9578-93dd1e20c836

Now, we will add a product to the category using Postman.

  • Log in to your Postman and create a new workspace.
  • Create a new POST with this URL:
https://www.wixapis.com/stores/v1/collections/{id}/productIds

-HEADER:  ‘Authorization: <ACCESS TOKEN>’

beehexa wix api add a product to the category post
Beehexa – Wix API How to add a product to the category post

In the body, enter the code.

Payload:

{
    "productIds": [
        "61ea866c-1564-401d-aa5e-1a2fc1bf28ed"
    ]
}
beehexa wix api add a product to the category body
Beehexa – Wix API How to add a product to the category

You can easily add more than one product to a category, it depends on your requirement in the body section with the code.

Then, Click send.

Response: 

As you can see, the Postman returned the empty array.

{}
beehexa wix api add a product to the category response
Beehexa – Wix API How to add a product to the category response

Step 4: Verify the result

Now, we will verify the category.

  • Go to the Wix dashboard
  • Choose store products 
  • Click on categories

As you can see, the product has been added to the category successfully.

The above steps are to add a product to the category using Postman with Wix API. The next article will explore Wix rest API and multiple ways to make API calls. 

If you have any questions, let us know in the comment below or refer to our Wix API documentation.

These steps will be shown visually in the infographic below.

beehexa infor wix api how to add a product to the category using postman
Beehexa – Wix API How to add a product to the category using postman

Or you can watch this video for more overview.

Wix API – How to add a product to the category using Postman

Hopefully, you can do it!