07-20-2017 11:44 AM
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.
Solved! Go to Solution.
07-26-2017 07:18 PM
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?
07-27-2017 02:28 AM
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.
07-27-2017 11:14 AM
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.
07-31-2017 08:26 AM
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.
08-24-2017 10:00 AM
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
09-19-2017 11:35 AM
Thanks James. It's exactly what we need.
02-19-2019 12:24 PM
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?
02-19-2019 02:00 PM
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:
02-20-2019 02:18 AM
Hi MilanR,
I didn't know how add header, now it is clear for me. It works correctly. Thank you very much!
bego