Creating products is a must for every business running on an eCommerce website. That is the reason. Today Beehexa will show you how to create a product using Postman with Wix API.
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 API will return the new access token and the refresh token in order to request a new access token.
{
"refresh_token": "OAUTH2.eyJraWQiOiJkZ0x3cjNRMCIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiaWRcIjpcIjc2ZmQ4ZTc4LWVmMWItNDFmNC05MzUyLTk2ZWU4NGQzM2NkNlwifSIsImlhdCI6MTY1NDY1NDMyMiwiZXhwIjoxNzE3NzI2MzIyfQ.E8OMrqqR_d2lNb-ztHDFhyfjG2leKIVofA_UDJQkhg4",
"access_token": "OAUTH2.eyJraWQiOiJLaUp3NXZpeSIsImFsZyI6IlJTMjU2In0.eyJkYXRhIjoie1wiYXBwSWRcIjpcIjBhOGEwZjkxLTc0MjAtNDA0My04NTJmLTM2MWU2ZWNhZGQ3OVwiLFwiaW5zdGFuY2VJZFwiOlwiODQ1ZWY0NTAtOWZmZi00NDRlLWJkMzYtY2JlMmRlZDZlODI4XCIsXCJzY29w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b_QK0i5PyVOPuLp32ZaIMkeHaH4D6QehZEKeXxchxtXXViXW9ZDRTulFys2keDbyBdwNE8RXENEo71XiUXnQFOh5cKqJavN-nngXOfoHYKcs0c2F57pgspy1eCXuL4ooh9fXJKbI8l4draouuTEsEw"
}
Code language: JSON / JSON with Comments (json)
Step 3: Create a product using Postman
Now, we are ready to create a product using Postman with Wix API.
- Log in to your Postman and create a new workspace
- Create a new POST with this URL:
https://www.wixapis.com/stores/v1/products
Code language: JavaScript (javascript)
-HEADER: ‘Authorization: <ACCESS TOKEN>’
In the body section, enter the code:
Payload:
{
"product": {
"name": "T-shirt",
"productType": "physical",
"priceData": {
"price": 10.5
},
"description": "nice summer t-shirt",
"sku": "129df",
"visible": false,
"ribbon": "Sale",
"brand": "Nice",
"weight": 0.2,
"discount": {
"type": "AMOUNT",
"value": 1
},
"manageVariants": true,
"productOptions": [{
"name": "Size",
"choices": [{
"value": "S",
"description": "S"
},
{
"value": "L",
"description": "L"
}
]
}]
}
}
Code language: JSON / JSON with Comments (json)
Response:
The API will return all product information.
{
"product": {
"id": "61ea866c-1564-401d-aa5e-1a2fc1bf28ed",
"name": "T-shirt",
"slug": "t-shirt",
"visible": false,
"productType": "physical",
"description": "nice summer t-shirt",
"weightRange": {
"minValue": 0.0,
"maxValue": 0.2
},
"stock": {
"trackInventory": false,
"inStock": true,
"inventoryStatus": "IN_STOCK"
},
"price": {
"currency": "VND",
"price": 10.5,
"discountedPrice": 10.0,
"formatted": {
"price": "11₫",
"discountedPrice": "10₫"
}
},
"priceData": {
"currency": "VND",
"price": 10.5,
"discountedPrice": 10.0,
"formatted": {
"price": "11₫",
"discountedPrice": "10₫"
}
},
"convertedPriceData": {
"currency": "VND",
"price": 10.5,
"discountedPrice": 10.0,
"formatted": {
"price": "11₫",
"discountedPrice": "10₫"
}
},
"priceRange": {
"minValue": 10.5,
"maxValue": 10.5
},
"costRange": {
"minValue": 0.0,
"maxValue": 0.0
},
"additionalInfoSections": [],
"ribbons": [
{
"text": "Sale"
}
],
"media": {
"items": []
},
"customTextFields": [],
"manageVariants": true,
"productOptions": [
{
"optionType": "drop_down",
"name": "Size",
"choices": [
{
"value": "S",
"description": "S",
"inStock": true,
"visible": true
},
{
"value": "L",
"description": "L",
"inStock": true,
"visible": true
}
]
}
],
"productPageUrl": {
"base": "https://content313.wixsite.com/mysite",
"path": "/product-page/t-shirt"
},
"numericId": "1654705207181000",
"inventoryItemId": "9e157993-ea9b-bfe2-55a1-e5d03e40d712",
"discount": {
"type": "AMOUNT",
"value": 1.0
},
"collectionIds": [
"00000000-000000-000000-000000000001"
],
"variants": [
{
"id": "4c7eaa5e-2f40-4325-a1ac-6b2f6506a236",
"choices": {
"Size": "S"
},
"variant": {
"priceData": {
"currency": "VND",
"price": 10.5,
"discountedPrice": 10.0,
"formatted": {
"price": "11₫",
"discountedPrice": "10₫"
}
},
"convertedPriceData": {
"currency": "VND",
"price": 10.5,
"discountedPrice": 10.0,
"formatted": {
"price": "11₫",
"discountedPrice": "10₫"
}
},
"weight": 0.2,
"sku": "129df",
"visible": false
}
},
{
"id": "42f2386e-58f8-4719-a3d3-7dd37fc0aff2",
"choices": {
"Size": "L"
},
"variant": {
"priceData": {
"currency": "VND",
"price": 10.5,
"discountedPrice": 10.0,
"formatted": {
"price": "11₫",
"discountedPrice": "10₫"
}
},
"convertedPriceData": {
"currency": "VND",
"price": 10.5,
"discountedPrice": 10.0,
"formatted": {
"price": "11₫",
"discountedPrice": "10₫"
}
},
"weight": 0.2,
"sku": "129df",
"visible": false
}
}
],
"lastUpdated": "2022-06-08T16:20:07.181Z",
"createdDate": "2022-06-08T16:20:07.181Z",
"ribbon": "Sale",
"brand": "Nice"
}
}
Code language: JSON / JSON with Comments (json)
Step 4: Verify the result
After creating the product, you can check the result in the Wix Admin.
- From Wix Dashboard.
- Click on Store products.
- Choose Products.
As you can see, the product has been created successfully.
The above are all steps to create a product 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.
Or you can watch this video for more overview.
Hopefully, you can do it!