Configuring an API Key for an Outbound REST Message

simulationelson
Kilo Contributor

I'm new to ServiceNow and currently trying to configure an outgoing REST message for the first time. I'm checking out https://currency-exchange.p.mashape.com/exchange and have already obtained my API key. The problem is, how will I configure the API key, when in the Outbound > REST Message module you can only configure either Basic or OAuth 2.0 for the authentication? Or am I missing something here?

{"message":"Missing Mashape application key. Go to http:\/\/docs.mashape.com\/api-keys to learn how to get your API application key."}
1 ACCEPTED SOLUTION

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Nelson,



Is the far end expecting the api token in the header?


You can set name-value pairs in the header.


RESTMessageV2 - setRequestHeader(String name, String value)



Best Regards



Tony


View solution in original post

7 REPLIES 7

Hello Tony,



My apologies for the late reply. I came across the Mashape Docs - Authentication Settings and found out that the API key can be used as a parameter. I then looked up another API which returns a list instead of a value and it works:


https://mashape-community-urban-dictionary.p.mashape.com/define?mashape-key=<API key>&term=lol


In the Outbound > REST Message module as the get method this would translate to:


Endpoint: https://mashape-community-urban-dictionary.p.mashape.com/define


HTTP Headers:


    Name: Accept     Value: text/plain


    Name: X-Mashape-Key     Value: <API key>


HTTP Query Parameters:


    Name: term     Value: lol


I haven't gone as far as the actual scripting part just yet but this already proves your first answer was correct; The API key just needs to be set in the header.



Thanks!


Hi Nelson,



That is excellent news!


Consider marking the question as answered so Community members can benefit from your investigation.



Best Regards



Tony


Tharun Neeli
Kilo Contributor

Thanks @tony.barratt this works for us when we don't have "Basic Auth" OR "OAuth 2.0" and we have only API token to access, adding to header would be a better solution.