Support » Plugin: License Manager for WooCommerce » Struggling with License Update in API with .net

  • Resolved stigzler


    hi – firstly neat plugin. Love it.

    I’m developing a .net library for this. Have implemented all the GET operations without a hitch. However, I’m struggling to interface with the API for PUT operations (and possibly, by extension, POST). I’m getting a http 404 error from the server, despite the license key being right. I don’t know if you work with .net, but some code:

    Public Function HttpPut(netquery As String, json As String) As WebClientResponse
            Dim response As New WebClientResponse
            Using client As New CustomWebClient(WebClientTimeout)
                With client
                    .Encoding = Encoding.UTF8
                    .Credentials = Credentials
                    .Headers(HttpRequestHeader.ContentType) = "application/json"
                End With
    	    With response
    	       .ReturnedString = client.UploadString(netquery, "PUT", json)
    	       .Success = True
                End With         
    	End Using
    	Return response
        End Function

    CustomWebClient is just an extension allowing custom time outs. Credentials are exactly the same as for the working GETs. The content of netquery is right (same as the successful GETS). The client.UploadString params:

    netquery (with changes to preserve security):


    Difficulty being, I only have the HTTP error to go on so it’s hard to figure what’s going on with the API. Could you assist?

    • This topic was modified 1 year, 5 months ago by stigzler.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter stigzler


    P.S. I also tested it with this tool to take it away from my code. It returned this:

        "code": "lmfwc_rest_data_error",
        "message": "The license key could not be updated.",
        "data": {
            "status": 404

    Not sure why the update is not allowed? Are there any fields that are off limits for updates or throw the update?

    EDIT: It does appear to do with what json you place in content. This produces the above error:


    But this works:

    • This reply was modified 1 year, 5 months ago by stigzler.
    • This reply was modified 1 year, 5 months ago by stigzler.

    Hello @stigzler

    This is the method that handles the “Update license” request:

    As you can see the error “The license key could not be updated” happens near the end of the function, when the plugin tries to actually update the license key in the database.

    I Suspect that the JSON you sent is invalid, because of the “casing” of your body. Check out the docs here:

    Try to use snake case in your JSON body, i.e. order_id instead of `orderID.

    Let me know if that works.

    PS: If you’re willing to submit the library, I would be happy to feature it on my website 🙂

    Thread Starter stigzler


    Hi Drazen – thanks for this. Yeah – missed that detail! All good now, thanks

    Happy to share my library with you. I’m afraid I’m not a professional developer or anything – I’m just a hobby coder but take a look at it and do with it as you see fit. I will forward it when it’s finished.

    There are a couple of things that would be helpful in its dev which I can’t find in the docs. Mainly, what are the constraints around Update and Create Licence? I.e. what are the mandatory fields for each and what causes exceptions? (I think I’ve established that barest minimum for Create is Key and Status)

    I could trawl through your code, but my WP coding knowledge is poor (hooks/filters etc) and you’ll know where to look of course!

    Thanks again for your plugin – it’s awesome!


    That’s good info, I’ll add a task to update the REST API docs for constraints. It would also be very helpful if you could find an example on how these constraints are documented on any other project, because I’m not sure how to format it.

    Here’s a link to the GitHub issue for this:

    Thread Starter stigzler


    Great stuff + gosh – I’ve no idea about how to set it out. I just wing stuff and make it up as I go along 😉


    I will try it your way then 🙂

    No worries though, I’m sure that I’ll find plenty of examples online.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Struggling with License Update in API with .net’ is closed to new replies.