Web Connection
Include an API Key in my https request
Gravatar is a globally recognized avatar based on your email address. Include an API Key in my https request
  VFPJCOOK
  All
  Nov 14, 2024 @ 01:13pm

I need to access a REST API from foxpro. Here are the instructions I have been given: The endpoint to retrieve the data is https://interfaceapi.cpso.com:PortNumberHere/cfs/roster

There is an Api Key that you need to include in your https request. Key: NameOfACompany Value: Wmj...................6uN

I have done this using postman. Takes about 1 minute. You put in the url and go to headers tab and put in the key and the value. You select GET as the verb and click Send. Works perfectly.

I have foxpro code that uses wwhttp and looks like this:

DO wwhttp
DO wwJsonSerializer

loHttp = CREATEOBJECT("wwHttp")
loSer = CREATEOBJECT("wwJsonSerializer")

lcurl="https://interfaceapi.cpso.com:<some com port number here>/cfs/roster"
lcJson = loHttp.Get(lcurl)

My question: Exactly what foxpro code needs to be added to the above code, that will add the key and value to the header of my request?

Thank You, John

Gravatar is a globally recognized avatar based on your email address. re: Include an API Key in my https request
  Carl Chambers
  VFPJCOOK
  Nov 14, 2024 @ 03:01pm

Hi John,
Try this...

loHTTP.AddHeader(<headerName>, <value>)

Carl

© 1996-2024