06-05-2020 12:59 PM - edited 06-05-2020 01:04 PM
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.
06-05-2020 03:22 PM - edited 06-05-2020 03:30 PM
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:
06-06-2020 03:17 AM - edited 06-06-2020 03:19 AM
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
06-06-2020 07:18 PM
Hi LarryDante,
The example demonstrated above that is specific to the lichess.org web service is attached.
06-01-2023 03:46 AM - edited 06-01-2023 04:05 AM
[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
06-01-2023 11:28 AM
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.
06-02-2023 03:34 AM
Hallo Milan, it works, thank you so much!
Zsolt