LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP GET method with message body

Solved!
Go to solution

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 

0 Kudos
Message 1 of 6
(7,501 Views)
Solution
Accepted by RICBAR

Seems to be a server-side issue?  Maybe I misunderstood what you were trying to get at?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 6
(7,476 Views)

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.


___________________
Try to take over the world!
0 Kudos
Message 3 of 6
(7,448 Views)

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.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 6
(7,433 Views)

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/

 

 

0 Kudos
Message 5 of 6
(7,410 Views)

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 

Message 6 of 6
(7,288 Views)