# How to setup this curl request?

**URL:** <https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343>\
**Category:** General\
**Created:** [29 January 2023 09:29 UTC](https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343 "2023-01-29T09:29:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimC1986](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/timc1986/32/63085_2.png) [@TimC1986](https://discourse.nodered.org/u/TimC1986)\
**Post date:** [29 January 2023 09:29 UTC](https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343/1 "2023-01-29T09:29:14Z")

</div>

Hi all

I like to use this curl request from SMA but I'm not familar with curl requests.  
I tried already some flows myself but with no succes, I get always a 401 fault response

Can some get me on track with this?

 ![Curl request](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b21e0f9f2b8e3b110f4a603dee8c70f6578079f5.png)

[https://sandbox.smaapis.de/geoforecast/index.html](https://sandbox.smaapis.de/geoforecast/index.html)

many thanks

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [29 January 2023 09:49 UTC](https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343/2 "2023-01-29T09:49:13Z")

</div>

Hi @TimC1986

For this, use the HTTP Request Node.

- Set it to **POST**
- Set the URL
- Add the Headers

And for the data you need to POST, in a Function node, send this to the configured HTTP Request Node.

```javascript
return {
    payload:{
        geoLocation:{

        },
        partialGenerators:[

        ]
    }
}

```

The `payload` is basically the data that you want to send  
set the return type also to the desired type

 ![Screenshot 2023-01-29 at 09.52.08](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/028b0d4dfed5e4a981f2f4c9bba72a999aba14f6.png)

If your getting 401 - that suggests it requires authentication?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [29 January 2023 10:03 UTC](https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343/3 "2023-01-29T10:03:55Z")

</div>

The swagger suggests it requires OAuth.  
I have never used it, but this node may help to obtain the token, which you can then pass to the HTTP request Node header collection

> **[node-red-contrib-oauth2](https://flows.nodered.org/node/node-red-contrib-oauth2)**
>
> node-red-contrib-oauth2 - An OAuth2 client which sends an oauth2Response object as output.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 January 2023 10:12 UTC](https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343/4 "2023-01-29T10:12:21Z")

</div>

It looks to me that an api key is required using headers Authorization: Bearer api\_key.

If you click authorize and add an api\_key, then select execute  
the curl has an added Authorization header

```auto
curl -X 'POST' \
  'https://sandbox.smaapis.de/geoforecast/v1/basic/power/Tomorrow' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer api_key' \
  -H 'Content-Type: application/json' \
  -d '{

```

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [29 January 2023 10:19 UTC](https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343/5 "2023-01-29T10:19:23Z")

</div>

AS @E1cid pointed out.

If your aim is to move this into a Node RED request, adding the api key to the header collection should have the same effect.

---

<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:** [30 March 2023 10:19 UTC](https://discourse.nodered.org/t/how-to-setup-this-curl-request/74343/6 "2023-03-30T10:19:43Z")

</div>

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