Rapid API - or indeed any API

Hi all,

I am trying to use the rapidapi service to make queries via an HTTP node. I have a function node that sets the parameters from rapid API:

GET /auto-complete?q=game%20of%20thr HTTP/1.1
X-Rapidapi-Host: imdb8.p.rapidapi.com
X-Rapidapi-Key: <<<<MY KEY>>>>
Host: imdb8.p.rapidapi.com

I can't seem to get the combination of payload + headers right to make the thing work. I get "invalid payload" as the error.

Any help most gratefully received.

[{"id":"d50e160a0f210ab9","type":"inject","z":"a17127c262dbc9e4","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":200,"y":420,"wires":[["3c2742aa6460c4e4"]]},{"id":"3c2742aa6460c4e4","type":"function","z":"a17127c262dbc9e4","name":"set payload and headers","func":"msg.headers = {};\nmsg.headers['X-Rapidapi-Host'] = 'imdb8.p.rapidapi.com';\nmsg.headers['X-Rapidapi-Key'] = '<<<<my key>>>>';\nmsg.headers['Host'] = 'imdb8.p.rapidapi.com'\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":420,"wires":[["0ad6ad365f7c349e"]]},{"id":"0ad6ad365f7c349e","type":"http request","z":"a17127c262dbc9e4","name":"IMDB","method":"GET","ret":"obj","paytoqs":"query","url":"https://rapidapi.com","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":610,"y":420,"wires":[["6160bb0b377e4cac"]]},{"id":"6160bb0b377e4cac","type":"debug","z":"a17127c262dbc9e4","name":"","active":true,"console":"false","complete":"false","x":770,"y":420,"wires":[]}]

I would go for:

msg.headers = {};
msg.headers = {
        'X-Rapidapi-Host':'imdb8.p.rapidapi.com', 
        'X-Rapidapi-Key' : '<<<<my key>>>>',
        'Host' : 'imdb8.p.rapidapi.com'
};
return msg;

Not sure what should be the msg.payload...

I get 'invalid payload' :frowning:

I don't know why I bother using rapidapi, I can only make use of any APIs when I am on their site. Their documentation is appalling, and it's the detail that matters.

Many thanks for the suggestion though, much appreciated.