# Rapid API - or indeed any API

**URL:** <https://discourse.nodered.org/t/rapid-api-or-indeed-any-api/63319>\
**Category:** General\
**Created:** [31 May 2022 18:12 UTC](https://discourse.nodered.org/t/rapid-api-or-indeed-any-api/63319 "2022-05-31T18:12:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![warwickhw](https://avatars.discourse-cdn.com/v4/letter/w/f9ae1b/32.png) [@warwickhw](https://discourse.nodered.org/u/warwickhw)\
**Post date:** [31 May 2022 18:12 UTC](https://discourse.nodered.org/t/rapid-api-or-indeed-any-api/63319/1 "2022-05-31T18:12:47Z")

</div>

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:

```auto
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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [3 June 2022 02:35 UTC](https://discourse.nodered.org/t/rapid-api-or-indeed-any-api/63319/2 "2022-06-03T02:35:25Z")

</div>

I would go for:

```auto
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...

---

<div class="post-metadata">

**Author:** ![warwickhw](https://avatars.discourse-cdn.com/v4/letter/w/f9ae1b/32.png) [@warwickhw](https://discourse.nodered.org/u/warwickhw)\
**Post date:** [4 June 2022 11:07 UTC](https://discourse.nodered.org/t/rapid-api-or-indeed-any-api/63319/3 "2022-06-04T11:07:24Z")

</div>

I get 'invalid payload' ☹

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 August 2022 11:08 UTC](https://discourse.nodered.org/t/rapid-api-or-indeed-any-api/63319/4 "2022-08-03T11:08:11Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
