Rest API with API Key

Rest API with API Key

  

Hi.

I've been trying to Consume a REST API to connect to a database of a third party I've been working with.

(*Note, I have changed some details for confidentiality reasons)

The GET URL is
https://apidev.outsystems.com/v3/status

I've been trying to put it in Outsystems 9, but I always get a message Invalid Key. Can anyone help me?



Example using Curl and header
$ curl --header "X-Api-Key: thisIsMyAPIKey" https://apidev.outsystems.com/v3/status
        

     

     

     

        If no or an invalid apikey is provided a         401 Unauthorized        is returned :     

        {
        "error": "Unauthorized",
        "message": "Missing api key",
        "status": 401
        }
    


        If a valid key is passed         200 OK        is returned :     

        {
        "message": "ok",
        "status": 200
        }

Hi,


how do you consume it in outsystems and how do you add the header?


Right Click Rest API

Consume API (Single Method)

I add the URL in the Top.

I add an example of this response in the Body

I have tried to add
X-Api-Key: 

as the response header

and this as the request header

thisIsMyAPIKey

But when I test it it gives me an Invalid API key.


However, I want it to send me an OK response with the actual API key. I'm obviously doing something wrong. But I don't know what!!


Solution

err,

couple of things.

you only need to add a request-header, and that should be "X-Api-Key"

(don't add the colon : to it, and also not the double-quotes ofcourse)

and then in the Test-Tab you enter the "thisIsMyAPIKey"



Solution

Cheers! 

"X-Api-Key" save my day. Thanks