Reputation: 89
I am working with Rad Studio (Delphi) and I am trying to connect to a RapidApi Endpoint via a Rest Component of Rad Studio. Although I use the "x-rapidapi-key" & "x-rapidapi-host" as parameters on the Rest Component, I get a 401 unauthorized Response. Any Ideas? Thank you
Upvotes: 1
Views: 1643
Reputation: 537
It's unclear but probably you need to pass x-rapidapi-host
and x-rapidapi-key
as the request headers, not parameters.
For example, try something like this
var axios = require("axios").default;
var options = {
method: 'GET',
url: 'https://example.p.rapidapi.com/',
params: {query: 'something here'},
headers: {
'x-rapidapi-host': 'example.p.rapidapi.com',
'x-rapidapi-key': '12345'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
Upvotes: 1