Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter gardenaway

    (@gardenaway)

    Interestingly, tried https and the result is as follows. Could it be that the request is not coming from the owner?

    <!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
    <html>
    <head>
    <title>403 Forbidden</title>
    </head>
    <body>
    <h1>Forbidden</h1>
    <p>You don’t have permission to access /wp-json/lmfwc/v2/licenses
    on this server.
    <br />
    </p>
    <hr>
    <address>Apache/2.4.33 (Win64) OpenSSL/1.1.0g PHP/7.0.29 Server at local-shop.ideolio.com Port 443</address>
    </body>
    </html>

    Thread Starter gardenaway

    (@gardenaway)

    Never mind about https. Can’t get to server as it is only via http. Original problem remains.

    Suggestions most welcome.

    Hello @gardenaway,

    thank you for your message and for using my plugin.

    I just noticed that I didn’t make it clear, that the v2 endpoints are not part of the plugin yet. They are coming in an update to be released in 3 days (on September 1st). That is why the route doesn’t exist.

    As for HTTP/HTTPS. By default, the API doesn’t work over insecure HTTP connections. It requires HTTPS to work. However, there is a setting to disable this to make it work with HTTP. I would highly discourage you from using it like that in a productive environment.

    I can’t however figure out why you’re getting a 403. I did some googling and found out that this could be related to the mod security setting on the server. Perhaps that’s worth looking into?

    Thread Starter gardenaway

    (@gardenaway)

    Thanks Drazen,

    Yes, I’ve tried v1 and and I have the HTTP option set for development only. But the error persists.

    We use the WP API all the time both in production (HTTPS) and development (HTTP) w/o 404.

    Here’s the request:

    https://local-shop.ideolio.com/wp-json/lmfwc/v1/licenses?consumer_key=xxx&consumer_secret=yyy

    and the response:

    {
    “code”: “rest_no_route”,
    “message”: “No route was found matching the URL and request method”,
    “data”: {
    “status”: 404
    }
    }

    Are there a few spots in the plugin where I could add debug statements to try to narrow down the issue?

    Thanks again for the great plugin. Lots of potential!

    @gardenaway,

    https://local-shop.ideolio.com/wp-json/lmfwc/v1/licenses?consumer_key=xxx&consumer_secret=yyy

    Is this a PUT or GET request? Because such a PUT request doesn’t exist. That’s maybe why you’re getting the error. Please try the following request:

    GET - https://local-shop.ideolio.com/wp-json/lmfwc/v1/licenses?consumer_key={{consumer_key}}&consumer_secret={{consumer_secret}}

    Let me know if that works!

    Thread Starter gardenaway

    (@gardenaway)

    Good catch! Yes, the GET works. So it is not the route. I was trying different API calls to figure out why activation was not working put forgot to change GET/PUT.

    My original problem was testing the activation of a key with PUT:

    https://local-shop.ideolio.com/wp-json/lmfwc/v1/licenses/activate/8ADZJ2K5KONTKZLP8BWTRIIS?consumer_key=xxx&consumer_secret=yyy

    which returns:
    {
    “code”: “rest_invalid_param”,
    “message”: “Invalid parameter(s): license_key_id”,
    “data”: {
    “status”: 400,
    “params”: {
    “license_key_id”: “license_key_id is not of type integer.”
    }
    }
    }

    @gardenaway,

    yup, sounds about right. That was a design problem with the old v1 routes, and that is also the one reason why they are currently deprecated and will be removed in the future.

    You see, when I originally created the API, i envisioned the retrieval, activation, and every other API action to be done by the license key ID, which is the primary key in the database. This, of course, was a bad idea. But it stuck and that’s what it is at the moment. This means that you cannot activate a license key by the license key itself (boo!), you need its ID (boo!).

    I strongly suggest that you wait until Sunday, then the v2 routes will be available and you can then activate license keys by the actual license key. If you can’t wait until Sunday, you can pull the DEV version from GitHub, install it, and start working on it right away. Here’s the link:

    https://github.com/drazenbebic/license-manager-for-woocommerce/tree/DEV

    Thread Starter gardenaway

    (@gardenaway)

    Thanks for the clarification. Sunday is good.

    Our product is a free web app that users buy keys to add functionality.

    For each of these add-ons, they go to our store, buy the add-on then paste the key in web app. The web app calls back to the server with the key to invoke the activation API.

    Question: Would like to verify that the key that the user has provided matches the SKU of the add-on they have purchased. Is it possible to query the plugin to get the product SKU for the given key (or something like that).

    @gardenaway,

    you can use the GET - v2/licenses/{license_key} endpoint first. This endpoint will return you all available license key data. Then, you can take the product_id and query the WooCommerce API for the product data. If the product data matches, then you send an activate request. This method will require you to do two additional API calls though. You will also need to generate separate API credentials for the WooCommerce API.

    However, this got me thinking. Probably a lot of people will want to add or remove some data from the endpoint response. Perhaps adding a filter to each response, before it’s being sent out, makes sense. That way you could manipulate the response data before you send it out.

    I could probably also squeeze this into the release on Sunday. That way you wouldn’t have to query the WooCommerce API. Would that work for you?

    Thread Starter gardenaway

    (@gardenaway)

    Yes, cutting down API calls is always a good thing. We find the WP REST interface to be very slow. 3 calls to accept a key from a user could take several seconds which from a UX perspective isn’t very attractive.

    I don’t follow your filter proposal, but that’s OK. As long as we can validate the key against the product and minimize API calls.

    Looking forward to v2!

    @gardenaway,

    I’m not sure how familiar you are with WordPress plugin/theme development, but filters are WordPress-specific functions, also known as “hooks”. They offer the ability for people who want to extend the functionality of existing code to “hook in” and modify the functions output. Basically, this will allow you to modify any and all API responses from inside the server.

    Version 2.0.0 is looking good and will be released on time. Stay tuned ??

    PS: Once you start using the plugin, I would be extremely thankful if you could write a plugin review here on www.ads-software.com. Those reviews really help the plugin grow and mean a lot to me personally.

    I’ll mark this topic as resolved, since we solved the original problem ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘API rest_no_route’ is closed to new replies.