03-07-2016 07:08 PM
Hi all,
I'm working with an API using HTTP to make the calls to a server. I encountered an API call in the documetnation that uses the HTTP GET method with a message body. It seems that this is not supported by LV14 as I do not see a message body input for the LabVIEWHTTPClient.lvlib:GET.vi function. The POST and PUT methods seem to be forbidden for this API call, I get a 405 not found. I might be stuck with using a GET.
Granted, this is not the recommended use of the GET method - however it is not explicitly forbidden in the HTTP/1.1 specification. Is there a workaround for submitting a HTTP GET request with content? Would I have to use an external HTTP DLL to achieve this?
Any inputs would be great.
Thanks,
Richard
Solved! Go to Solution.
03-07-2016 07:33 PM - edited 03-07-2016 07:37 PM
Seems to be a server-side issue? Maybe I misunderstood what you were trying to get at?
03-08-2016 02:23 AM
I don't know the details about what GET does or doesn't allow, but as a backup, you don't have to call external code. Ultimately, it's just HTTP, so you can use the TCP primitives to open a connection and write your data to it. You will need to find the documentation on exactly how to build a GET request (or fire up a sniffer like Wireshark and copy the data from a sample GET). Encryption might be an issue and there might be others I haven't thought of.
Another option is probably to use .NET. I expect there is something shipping with Windows which does support encryption and possibly your use case too.
03-08-2016 04:30 AM
If you can't do it with the HTTP Client VIs, then either try .NET httpclient (or some variation of it) or do as TST suggested and implement it yourself using the TCP/IP VIs.
I would also question that while not strictly prohibited, it doesn't really follow the conventions/standards of HTTP so I would suggest getting in touch with the API provider.
03-08-2016 09:57 AM - edited 03-08-2016 09:58 AM
I had a similar case where I needed to use a "PATCH" method to submit data to Salesforce.com. No PATCH in the LabVIEW API.
The HTTP libraries use CURL under the hood, and I found on the Salesforce.com website a way to override the method by appending it to the URL.
Maybe you can use the LabVIEW API POST function to supply the body, then override the method as GET by appending to the URL.
https://lavag.org/topic/19273-labviewhttpclientlvlib-patch-method/
03-21-2016 03:34 PM
Thanks for your suggestions everyone. I looked into other libraries to find ways of doing a GET with message, but I ended up thinking that this is a bad idea due to us not following the spirit of the HTTP spec.
As Bill said, this is a server-side API definition problem. I ended up calling a few meetings and got it changed.
Thanks,
Richard