LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using HTTP PUT

Solved!
Go to solution

Hello All!  I am trying to use HTTP PUT in labview 2014 to send a command to remote ethernet device to turn on a buzzer.  I can successfully send the command and get the buzzer to turn on using a tool like PostMan (google App tool), however, when I try to do it in labview I keep getting Error 400 bad content.  I can do a HTTP GET and it works just fine.  I figure it is a format issue? I have tried several combinations with adding different header info as well as taking out the open handle, etc.  I'm sure it is probably something simple, so any ideas would be appreciated!.  I have attached a pic of the code for reference that I have been playing around with.  Thanks!

HTTPIssue.jpg

0 Kudos
Message 1 of 6
(4,358 Views)

Have you created a Web Service within the project that houses your HTTP Put VI?  If you haven't done that, it is totally possible that all your code is correct but LabVIEW has no means through which to communicate with HTTP.  

 

Here's how to create a Web Service:  

http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/build_web_service/

 

Check out this link for some more information:  

http://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/webservices/

 

If your web service has been created, published, and is running and you are still seeing this error, we'll start to take a deeper look at your code. 

Matt | NI Systems Engineering
0 Kudos
Message 2 of 6
(4,309 Views)

The error you are getting back in the header response is quite clear - "bad content-type: text/plain". You need to find out what content-type the server is expecting (e.g. if it's JSON then it should probably be application/json).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 6
(4,275 Views)
Solution
Accepted by topic author jmyers

My colleague downloaded wire shark and was able to find out that the labview HTTP PUT was sending additional TCP information that my device was not expecting and so my device sent back the bad content error.  I ended up just using a TCP write and got it to work correctly.  Thanks for all the help!

0 Kudos
Message 4 of 6
(4,188 Views)

I am having exactly the same issue with the HTTP VIs.  I tried using TCP as you suggest, but I can not figure out what to do with the directory path information after the IP address.  In your example, you have ip_address/factoryManager/test.  Can you let me know what you do with the /factoryManager/test part?  The open TCP VI only likes having the IP address specified.   Thanks.

0 Kudos
Message 5 of 6
(3,501 Views)

No need to reply to my previous post.  I just learned from a different thread, that I needed to force the "expect" header to an empty string.

0 Kudos
Message 6 of 6
(3,489 Views)