How to get coupon times used with coupon code using REST Api?

I have no experience with Magento. I was asigned the task to validate a coupon code via magento rest api. I've tried to use /V1/coupons/search GET method. My request url is:

 https://example.com/index.php/rest/V1/coupons/search/?searchCriteria[filterGroups][0][filters][0][field]=code&searchCriteria[filterGroups][0][filters][0][value]=12345ABC&searchCriteria[filter_groups][0][filters][0][condition_type]=eq

However, my java based server receives a 500 status response.

I've also tried to make a curl request like this:

curl -X GET --header "Authorization: Bearer some-token-string"

https://example.com/index.php/rest/V1/coupons/search?searchCriteria[filterGroups][0][filters][0][field]=code&searchCriteria[filterGroups][0][filters][0][value]=1234ABC&searchCriteria[filter_groups][0][filters][0][condition_type]=eq"

However my console responds:

curl: (3) [globbing] error: bad range specification after pos 92

Any help would be much appreciated. Thanks in advance!

Solutions

In Magento 2x: vendor/magento/module-sales-rule/etc/webapi.xml

Check all coupon related APi End Point

<!-- Coupon CRUD -->
    <route url="/V1/coupons/:couponId" method="GET">
        <service class="Magento\SalesRule\Api\CouponRepositoryInterface" method="getById"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>
    <route url="/V1/coupons/search" method="GET">
        <service class="Magento\SalesRule\Api\CouponRepositoryInterface" method="getList"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>
    <route url="/V1/coupons" method="POST">
        <service class="Magento\SalesRule\Api\CouponRepositoryInterface" method="save"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>
    <route url="/V1/coupons/:couponId" method="PUT">
        <service class="Magento\SalesRule\Api\CouponRepositoryInterface" method="save"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>
    <route url="/V1/coupons/:couponId" method="DELETE">
        <service class="Magento\SalesRule\Api\CouponRepositoryInterface" method="deleteById"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>

    <!-- Coupon Management -->
    <route url="/V1/coupons/generate" method="POST">
        <service class="Magento\SalesRule\Api\CouponManagementInterface" method="generate"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>
    <route url="/V1/coupons/deleteByIds" method="POST">
        <service class="Magento\SalesRule\Api\CouponManagementInterface" method="deleteByIds"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>
    <route url="/V1/coupons/deleteByCodes" method="POST">
        <service class="Magento\SalesRule\Api\CouponManagementInterface" method="deleteByCodes"/>
        <resources>
            <resource ref="Magento_SalesRule::quote"/>
        </resources>
    </route>

Try adding the --globoff argument to your curl command. Curl's globbing feature is misinterpreting the braces in Magento's query syntax as a request for curl to make multiple requests based on a range.

E.g.

curl -X GET --globoff --header "Authorization: Bearer some-token-string" https://example.com/index.php/rest/V1/coupons/search?searchCriteria[filterGroups][0][filters][0][field]=code&searchCriteria[filterGroups][0][filters][0][value]=1234ABC&searchCriteria[filter_groups][0][filters][0][condition_type]=eq"

Documentation for the feature is available here:

https://ec.haxx.se/cmdline-globbing.html

Similar questions

How to create coupon code to be used only by people who have subscribed to the newsletter
I need a help to create a 15% OFF coupon code for products. This coupon is only for people who have subscribed to our newsletter. As far as I know, there is no option in Magento to do so, but is there anyone who can help me in this?
Added product via REST API OAuth not retrieved and not able to update via REST API
After adding product to Magento run http://mymagentohost/api/rest/products/40 it will return Resource not found but if just open product from Magento and click on save (without changing anything) than (run http://mymagentohost/api/rest/products/40) it will return product in xml view. some code for saving product using REST OAuth as below Response I...
Rest Api - call custom rest api function
i am beginner in creating Rest api, i dont know from where to start. till now am able to pull products list using http://my_host.com/api/rest/products. but am confused what will my url for calling custom function
Rest API - Post method to magento/api/rest/products returns 404
Posting product data via magento/api/rest/products returns a 404 but saves the data. Any ideas why this is occurring? If I do a get request I get a 200, this is only occuring on a post method. So I looked in my logs, and I see an error after the post. File not found api/rest/products/27 Which is wrong is should be magento/api/rest/products/27 "POST...
How to extend rest API request or check request from web or rest API?
I have created a module for checkout payment methods event. But I need to check request is getting from web or rest API. I mean something like: Please Help me
Rest API - magento 1.9 - Return 403 Access denied - Magento\Framework\Webapi\Exception::HTTP_FORBIDDEN - format - https://abc.in/api/rest/customers
Error : Rest API for customer return 403 access denied error. Format : website/rest/api/customer -> 403 access denied error Magento\Framework\Webapi\Exception::HTTP_FORBIDDEN

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.