LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use labview to send a JSON via PUT to a server?

Hello,

I want to send a JSON via http put to a server. The first step was done with postman and it works as desired.

Now it's time to implement it in LabVIEW. The generation of the JSON already works. Currently I am stuck with sending the data.

What have I done so far.

 

I generate the necessary URL as I use it in postman and send the JSON (contained in the string buffer) with the http put vi. The following error message appears.

2020-01-25_16h28_11.png2020-01-25_16h27_35.png

 

Because I have to include a local proxy I have added in front of the URL the following: http://localhost:3128/

 

With this change, the error message also changes to:

2020-01-25_16h40_25.png

 

What I currently do not know:

  • Is my approach right or am I basically doing something wrong?
  • How do I set up the proxy correctly?
  • How do I know if I need to include additional headers? Can I "intercept" the communication in postman to see if any data is sent besides the actual JSON?

 

Can you give me examples of how to communicate with a server that sends a JSON? Unfortunately I have not found anything in my search so far.

 

Thank you very much and best regards
Michael

0 Kudos
Message 1 of 5
(3,141 Views)

With regards to proxies, you might find this thread useful:  http through proxy connection 

There's some code and discussion there by both the OP and rolfk, which might help. Otherwise, on the second page an NI staff member discusses CURL options via environment variables that can be used to control proxy behaviour.

 

With regards to your first question, looking at your included code images I'd say you'd be fine if you didn't need to use a proxy.

 

 


GCentral
0 Kudos
Message 2 of 5
(3,067 Views)

Thanks a lot for your help. How can I make the generated package, considting header, json, ... which will be send through the http put visible? I want to be sure, because in postman it is working, that I have configured everything right in labview.

 

Thanks a lot.

 

Best regards,

Michael

0 Kudos
Message 3 of 5
(2,828 Views)

How is Postman configured? Is it configured to validate the server certificate or has than been disabled. You second error seems to indicate that your LabVIEW code is trying to verify the server certificate and it cannot. There is an optional "verify server"  input on the "Open Handle" VI that defaults to True. Try setting this to false and see if it works. If it does and you need to actually verify the server you will need to start messing with certificates on your computer. Specifically, you will need the CA chain for the server's certificate.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 5
(2,765 Views)

Hello,

I use Px as local proxy. Px is a HTTP(s) proxy server that allows applications to authenticate through an NTLM or Kerberos proxy server, typically used in corporate deployments, without having to deal with the actual handshake. It is primarily designed to run on Windows systems and authenticates on behalf of the application using the currently logged in Windows user account. The advantage is that Px is able to use the currently logged in user's credentials automatically without requiring any user supplied credentials. This is accomplished by using Microsoft SSPI to generate the tokens and signatures required to authenticate with the proxy.

 

Testing with postman works. The LabVIEW Application ends up with error 363507.

2020-01-28_16h26_10.png2020-01-28_16h24_18.png

Using Fiddler to compare both communications (LabVIEW vs. Postman) the main difference is, that postman uses https and labview not.

2020-01-28_16h27_51.png

Any ideas?

Thanks for your help.

0 Kudos
Message 5 of 5
(2,578 Views)