How to setup this curl request?

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?

https://sandbox.smaapis.de/geoforecast/index.html

many thanks

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.

return {
    payload:{
        geoLocation:{

        },
        partialGenerators:[

        ]
    }
}

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

If your getting 401 - that suggests it requires authentication?

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

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

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 '{
1 Like

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.

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