LabVIEW Web Development Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview POST, PUT HTTP method

Solved!
Go to solution

Has anyone had Labview web service samples using POST or PUT HTTP method. I can only find examples using GET HTTP method. It will help to send data from client to server. Many thanks for the help.

Message 1 of 30
(43,007 Views)

Hi Noriker,

 

Are you trying to create a LabVIEW Web Service that is capable of listening to and responding to HTTP Post messages

 

or

 

are you trying to create a LabVIEW VI that is capable of sending a Post message to a Web Server?

 

 


Milan
0 Kudos
Message 2 of 30
(42,949 Views)

Hi MilanR, Thanks for the response. I'm trying to create a LabVIEW HTTP POST or PUT VI that is capable of sending control commands and update setpoints etc, to a NI web system Server. So the answer is latter. Any simple examples using javascript or python would be appreciated. Thanks.

0 Kudos
Message 3 of 30
(42,943 Views)

To perform an HTTP POST you can use the HTTP Client POST VI

 

The following example sends an HTTP POST message to the url http://httpbin.org/post with the text "This is a good string message" and shows the response in a string indicator.

 

post.PNG


Milan
Message 4 of 30
(42,941 Views)

Hi MilanR,

Thank you very much the sample code. Actually I want a sample code that can send POST message from a web browser (not VI) to a Labview web server. And I want to create a LabVIEW HTTP VIs responding to HTTP Post messages. Could you help please? Sorry that I was not clear before. Many thanks.

0 Kudos
Message 5 of 30
(42,922 Views)
Solution
Accepted by topic author Noriker

Hi Noriker,

 

I dont have an example I can send you but happy to share a screenshot from a POST I use to update configs.

 

The important bit is the first VI which is Read POST Data.vi from the web request class. The rest is plain LabVIEW then (and the method has to be set to POST in the web service config).

 

I know its probably too late now but thought I would share just in case!

 

Cheers,

James

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 6 of 30
(42,797 Views)

Thanks James. It's exactly what we need.

0 Kudos
Message 7 of 30
(42,704 Views)

Hello,

 

this is example POST .json maessage I need send to Web server:

 

POST /api/v2.0.0/mission_queue HTTP/1.1

Host: 172.25.114.242

Content-Type: application/json

authorization: Basic YWRtaW46OGM2OTc2ZTViNTQxMCQxNWJkZTkwOGJkNGRlZTE1ZGZiMTY3YTljODczZmM0YmI4YTgxZjZmMmFiNDQ4YTkxOA==

Cache-Control: no-cache

Postman-Token: adeaf324-f239-d273-e8ae-9f0f727187ca

 

{

"mission_id": "7ee4f301-eca5-11e8-83db-f44d3061dd25",

"parameters": [{"input_name": "Ciel", "value": "5c631aed-eca1-11b8-83db-f44d3061dd25"}]

}

 

the POST vi contain inputs url and buffer. I dont know how to manage to send this message to POST vi. Could somebody  help me with this?

0 Kudos
Message 8 of 30
(38,448 Views)

Hi bego777,

 

You can add headers to your POST request by using Open Handle VI to create a client handle and using the Add Header VI to add the header names and values to the request before you call POST.

 

You can also manage the JSON data as a cluster and use the Flatten to JSON Function to convert it to a string for the POST body.

 

The following is an example:PostWithHeaders.png

 


Milan
Message 9 of 30
(38,442 Views)

Hi MilanR,

 

I didn't know how add header, now it is clear for me. It works correctly. Thank you very much!

 

bego

0 Kudos
Message 10 of 30
(38,424 Views)