In Wix API, you can get product options availability using Postman based on product ID.
Today, Beehexa will show you how to do it in this article.
If this is the first time you make a 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 token and the refresh token 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
Code language: JavaScript (javascript)
- In the body section, enter the code.
Payload:
{
"grant_type": "refresh_token",
"client_id": <APP_ID>,
"client_secret": <APP_SECRET>,
"refresh_token": <REFRESH_TOKEN>
}
Code language: JSON / JSON with Comments (json)
Body Params:
NAME | TYPE | DESCRIPTION |
grant_type | string | Value must be set to โrefresh_tokenโ |
client_id | string | The App ID as defined in the Wix Developers Center |
client_secret | string | The Secret Key for your app as defined in your Wix Developers Center |
refresh_token | string | The 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.
Step 3: Get product options availability.
Before getting product options available, we will get the product ID because that parameter includes in the next call.
- From Wix dashboard
- Go to โStore productsโ
- Click on โProductsโ
- Then click on the product that you want to get the product ID.
- Finally, copy the product ID in the URL.
We will rely on the product ID and a product option to get the product options available.
Product ID = 61ea866c-1564-401d-aa5e-1a2fc1bf28ed
Product option = โSizeโ: โSmallโ
Now, we will get the product options available.
- Log in to your Postman and create a new workspace.
- Create a new POST with this URL:
https://www.wixapis.com/stores/v1/products/61ea866c-1564-401d-aa5e-1a2fc1bf28ed/productOptionsAvailability
Code language: JavaScript (javascript)
{id} = Product ID.
-HEADER: ‘Authorization: <ACCESS TOKEN>’
In the body, enter the code.
Payload:
{
"options": {
"Size": "Small"
}
}
Code language: JSON / JSON with Comments (json)
Click Send
Response:
As you can see, the Postman returned the product options availability like this.
{
"productOptions": [
{
"optionType": "drop_down",
"name": "Size",
"choices": [
{
"value": "S",
"description": "Small",
"inStock": true,
"visible": true
},
{
"value": "Large",
"description": "Large",
"inStock": true,
"visible": true
},
{
"value": "Medium",
"description": "Medium",
"inStock": true,
"visible": true
},
{
"value": "One size",
"description": "One size",
"inStock": true,
"visible": true
}
]
},
{
"optionType": "color",
"name": "Color",
"choices": [
{
"value": "rgb(0, 0, 0)",
"description": "Black",
"inStock": true,
"visible": true
},
{
"value": "rgb(255, 255, 255)",
"description": "White",
"inStock": true,
"visible": true
}
]
}
],
"availableForPurchase": false,
"managedProduct": true
}
Code language: JSON / JSON with Comments (json)
The above are all steps to Get Product Options Available using Postman with Wix API. The following 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.
Or you can watch this video for more overview.
Hopefully, you can do it!