I want to get all coupons that i created in the price rule section using the API just like the result of product/orders listing API.
2 Answers
You can use GET on "/V1/coupons/search"
-
-
Depends on what you are searching for. if you want to get "all" as you stated in the question, you don't need a search criteria Commented Jul 29, 2020 at 13:25
-
But when I tried this without any search criteria, I get missing filename error. Commented Jul 29, 2020 at 13:27
-
I have found the answer :
rest/V1/coupons/search?searchCriteria=all
From the above API, i got all the coupon codes, then i picked the rule_id which is 5 and put in the below API for getting details of that particular API/rest/V1/salesRules/5
Commented Aug 3, 2020 at 11:59
Yes we can use the following to get all the coupon codes via REST API.
GET - {{url_rest_api}}/rest/V1/coupons/search?searchCriteria=all
Auth - Bearer Token = ###
Body - Blank
Response
{
"items": [
{
"coupon_id": 2,
"rule_id": 5,
"code": "TEST123",
"times_used": 0,
"is_primary": true,
"type": 0
}
],
"search_criteria": {
"filter_groups": []
},
"total_count": 1
}