03-30-2016 11:21 AM
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!
Solved! Go to Solution.
03-31-2016 01:43 PM
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.
04-01-2016 04:32 AM - edited 04-01-2016 04:32 AM
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).
04-08-2016 10:39 AM
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!
08-01-2017 06:56 AM
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.
08-01-2017 04:17 PM
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.