LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to connect to a web server

Hello sir/mam,

I was trying to connect to a web server need to download the data from a web server where an API is hosted and to connect  get access to that API an API key is needed. I am not able to develop the desire program to  perform this task through which i can provide web server address and API key and start getting the data from the web server. The tried to make  a program, though i haven't work in web connectivity part before in LabVIEW can anyone please help me with the solution of this program in able to connect to the web server.

http.PNG

0 Kudos
Message 1 of 7
(2,592 Views)

Hi LarryDante,

 

The ConfigKey VI is "only works with NI Web servers" as described in the ConfigKey VI documentation.

 

The documentation for a Non-NI Web Server should indicate how the api key needs to be included in the request. Some common approaches are to require a specific header to be added to the request which can be done by using the AddHeader VI or to include the api key in the url as you make the request. The approach to use is specific to the Web Server you are communicating with.

 

As a quick example this is how the Web Service lichess.org/api documented that I include the api key. The Web Service documentation stated that the api key be included as part of a Authorization header as a bearer token. Again I want to emphasize this is the specific requirement for the lichess.org/api web service and it will likely vary for different servers. The following shows how the Authorization header was added and the Content-Type header as required by the documentation:

 

lichess.png


Milan
Message 2 of 7
(2,550 Views)

Thank you @MilanR for your support, i will try to include api in the URL using your block diagram, could you please provide the VI for it

 

 

0 Kudos
Message 3 of 7
(2,513 Views)

Hi LarryDante,

 

The example demonstrated above that is specific to the lichess.org web service is attached.


Milan
Message 4 of 7
(2,484 Views)

[update]

I have checked in LV2015, maybe the same http client toolkit  is used, but I don't have the autorization option there neither,

 

 

Hallo Milan,

 

I would like to ask for some help. Your solution is great, however, if I put an Add header to the block diagram (LV2019), in the list Authorization is missing. Should be my HTTP Clien package old, or how can this happen? I have the token, I just cannot add it to the header. 

 

Could you pls help me what to check / update?

 

Thank you in advance!

 

Zsolt

0 Kudos
Message 5 of 7
(1,034 Views)

The header input of the AddHeader VI is a string, not an enum, etc. You can wire in any valid header string. The combobox input helps to autocomplete some common header string values. It does not restrict what header you pass.


Milan
0 Kudos
Message 6 of 7
(1,009 Views)

Hallo Milan, it works, thank you so much!

 

Zsolt

0 Kudos
Message 7 of 7
(995 Views)