calling web API from VBA

Where are examples of URL's for doing things like changing custom license fields for a given product key?

I looked at the page for limelm.pkey.setDetails but that page doesn't describe how to use it. If I knew what the complete URL needs to be, I think I could do it.

Never call the web API from your app. Using the web API requires the web API key, which is like a password to your LimeLM account. So if you integrate the web API in your app you're giving your password to all users of your app.

What you should do is have a script on your website that does whatever you want it to do, and from your app call that script and pass along something from the user (like their product key) and whatever else you want to set.

Then the script on your website does the work.

Thanks for the reply.I want to call the web API from an Excel worksheet I use to manage licenses for my users. I would like modify values of custom license fields from there.

Custom license fields are, to the customer, read-only. You have to create a script on your servers if you want to modify those values.

What information are you trying to collect?

I want to change dates in some license fields, and integer values in others.

It sounds like this can't be done with a URL sent to wyday.com.

If I put LimeLM.php from the WebAPI.zip download onto my webserver, can a URL sent to this script from VBA change values stored in custom license fields? If yes, an example of how to do this would be great.

>> "I want to change dates in some license fields, and integer values in others."

If you were able to do that directly from your app (without first going through a script on your website) that would allow customers to input any value they want for any custom license fields.

That's why we recommend doing the work on your servers based on some algorithm you know.

>> "If I put LimeLM.php from the WebAPI.zip download onto my webserver, can a URL sent to this script from VBA change values stored in custom license fields?"

No, you also have to write the script that does the thing you want to do.

I'm not explaining myself very well.What I want to do is for me only, not for my customers.It is not going to be in my protected app.It will only by run by me, from an excel workbook where I keep a database of my customers.For example, on a worksheet I change the value of a custom license field for a customer. I then want to pass this change to my LimeLM account, for the product key used by that customer.Does that make sense?

Yeah, that makes sense. In that case the best option is probably to use our VB.NET or C# examples in the web API pack. We don't have a VBA example calling the web API functions, but you could build it yourself if you wanted.

I tried to open the VB.NET project in Visual Studio 2010 and Visual Studio 2012 Express, and neither would open it.

When trying to open LimeLM API.sln, one of the messages was "the project type is not supported by this installation" and another was "LimeLM API.vbproj' cannot be opened."My VS2010 has Visual Basic 2010.My VS2012 has Visual Basic 2012.Any idea what I'm doing wrong?

That project makes use of ASP.NET, which might not be supported by VS Express. Just open the LimeLM.vb file. That's what contains all the API calls.

I had already looked at the LimeLM.vb file, and I don't know how to port that to VBA. I copied the code to a VBA class module, but was not able to get very far with it because it uses methods I'm not familiar with.

If you have just one example of how to call a Web API function from VBA, that might be enough to get me going.

I don't know how to port LimeLM.vb to VBA. Can you give me an example, or hints on how to do this?

Well, there are lots of resources to do this: http://stackoverflow.com/questions/158633/how-can-i-send-an-http-post-request-to-a-server-from-excel-using-vba

But, honestly, it's probably just easier to manage your data within LimeLM.

Thanks for the reply. I have no idea how to "manage your data within LimeLM" other than through my wyday.com login account, and I find that very cumbersome for frequent editing of product keys.

My main goal is to edit existing product keys on a fairly frequent basis. Not to create new ones.

I have been working with that particular stackoverflow thread. But I'm missing something simple. Can you tell me why this fails?Sub doit() sURL = "https://wyday.com/limelm/api/rest/" Dim objHTTP As Object Set objHTTP = CreateObject("MSXML2.XMLHTTP") If TypeName(objHTTP) <> "IXMLHTTPRequest" Then Exit Sub objHTTP.Open "POST", sURL, False objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" objHTTP.setRequestHeader "ContentType", "application/x-www-form-urlencoded" objHTTP.send "api_key=blahblahblah.blahblah&method=limelm.test.echo" WebResponse = objHTTP.responseText Debug.Print WebResponseEnd Sub

Inserting my actual API Key, this produces is <?xml version="1.0" encoding="utf-8"?><rsp stat="fail"><err code="101" msg="Method &quot;&quot; not found"/></rsp>

You need to use "double ampersands" in strings so that they're properly evaluated: http://stackoverflow.com/a/23129364/124805

I'm still having trouble.objHTTP.send "api_key=blahblahblah.blahblah&&method=limelm.test.echo"I tried a double ampersand as shown above, but the result is exactly the same as with one.

Can this be done directly in the address field of Internet Explorer?I tried this in IE11 with my actual keyidhttps://wyday.com/limelm/api/rest/api_key=blahblahblah.blahblah&method=limelm.test.echoand after a long pause got this displayed in the browser window.

<?xml version="1.0" encoding="UTF-8"?>-<rsp stat="fail"><err msg="Method "" not found" code="101"/></rsp>

How about an example URL to show how to do lime.test.echo

Well, the URL you typed into the browser wouldn't work (you general shouldn't use "GET" to call APIs, but you didn't even make a correct GET call).

You did this:

https://wyday.com/limelm/api/rest/api_key=blahblahblah.blahblah&method=limelm.test.echo

You should do this:

https://wyday.com/limelm/api/rest/?api_key=blahblahblah.blahblah&method=limelm.test.echo

Thanks for the reply, Wyatt.

You're right. Putting ? in front of api_key got the URL to work in the browser address field. I never would have guessed a ? needed to go there.

But this didn't help my VBA code. It is still saying method not found when I try the following:objHTTP.send "?api_key=blahblahblah.blahblah&method=limelm.test.echo"

What else am I doing wrong?

Why did you say I shouldn't use GET. I'm not using GET, I'm using POST because of what I see in Limelm.vb objRequest.Method = "POST".

To see what would happen, I tried GET with the same URL string that worked in a browser, and that did return response text which indicated success. So should I do all API commands this way?

Success!I keep a database of my customers, their products keys and custom license fields on an Excel worksheet.I can now manage custom features from the worksheet with a few VBA macros. Like display, compare and update what's in Excel to what's on wyday servers. For my needs this is way better than using a web browser. 😀

Wyatt wrote:> Well, the URL you typed into the browser wouldn't work (you general> shouldn't use "GET" to call APIs, but you didn't even make a> correct GET call).> > You did this:> > > https://wyday.com/limelm/api/rest/api_key=blahblahblah.blahblah&method=limelm.test.echo> > You should do this:> > > https://wyday.com/limelm/api/rest/?api_key=blahblahblah.blahblah&method=limelm.test.echo

You save me. Why it is not clearly written somewhere in the documentation??? 😳