Beginner - get data from url API

I am trying to get Solax API data into Node red using http node on
Windows 10 laptop.
In google/chrome the API works.
In the http node I get jason parse errors

Any help gratefully received

Windows :-

/ 20220311124945
"// https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=202203012033514594849511&sn=SWRAZ6****"

{
"success": true,
"exception": "Query success!",........
"

Node red

Method
POST
URL

Enable secure (SSL/TLS) connection
Use authentication
Enable connection keep-alive
Use proxy
Only send non-2xx responses to Catch node
Return
a parsed JSON object
Name
Name
Tip: If the JSON parse fails the fetched string is returned as-is.

JSON parse error"

11/03/2022, 14:28:57node: solaxmsg.payload : string[746]

"<!doctype html>HTTP Status 405 – Method Not Allowedbody {font-family:Tahoma,Aria.......

Did you include your token in the Node-red request?

show us your flow (export it using CTRL+E) and paste into a code block in a reply

```
ALWAYS paste code and flow exports between backticks like this
```

Yes I included valid token

here are exported flows

My apologies I am very new to this.

[
    {
        "id": "81e3cc54d388cf82",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "29d135c8dc5cdb2b",
        "type": "modbus-client",
        "name": "Solax inverter",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "tcpHost": "5.8.8.8",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    },
    {
        "id": "e45f811e4ed26fa4",
        "type": "inject",
        "z": "81e3cc54d388cf82",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 80,
        "y": 120,
        "wires": [
            [
                "fb3df79207fada74"
            ]
        ]
    },
    {
        "id": "ededf1746c4a3338",
        "type": "debug",
        "z": "81e3cc54d388cf82",
        "name": "solax",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 230,
        "y": 300,
        "wires": []
    },
    {
        "id": "fb3df79207fada74",
        "type": "http request",
        "z": "81e3cc54d388cf82",
        "name": "",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "body",
        "url": "https://www.eu.solaxcloud.com:9443/proxy/api/getRealtime Info.do?tokenId=202203012033514594849511&sn=SWRAZ6TDH9/",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 150,
        "y": 220,
        "wires": [
            [
                "ededf1746c4a3338"
            ]
        ]
    }
]

Do you have to log in before you get access?

If I try the URL with your token i get ...
image

e.g. if you opened the link in a different browser (or INCOGNITO mode), do you get asked for a username / password?

I have just tried with incognito and it worked

it worked with no password requested

Your http request node is set to POST and the api uses GET.
p.s there is also a space typo in your url.

I have tried GET as well as POST
I get the same resulting error

Good news and bad
With space removed GET no parse errors, but same as
for you "no authority"
In Chrome I did not have to give any authority/password

Possibly because your credentials are cached?

Alternatively, the request might need to have certain headers set.

In chrome, open developer tools (usually F12) then switch to network tab, then refresh the page.
Inspect the headers sent in the request.
After that, set the headers you found in chrome into your node-red request (see cookbook for how to)

remove the closing /
this worked for me

[{"id":"e45f811e4ed26fa4","type":"inject","z":"81e3cc54d388cf82","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":140,"wires":[["fb3df79207fada74"]]},{"id":"fb3df79207fada74","type":"http request","z":"81e3cc54d388cf82","name":"","method":"GET","ret":"obj","paytoqs":"body","url":"https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=202203012033514594849511&sn=SWRAZ6TDH9","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":220,"wires":[["ededf1746c4a3338"]]},{"id":"ededf1746c4a3338","type":"debug","z":"81e3cc54d388cf82","name":"solax","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":230,"y":300,"wires":[]}]
{"inverterSN":"XM2202H7222024","sn":"SWRAZ6TDH9","acpower":155,"yieldtoday":3.1,"yieldtotal":25.7,"feedinpower":0,"feedinenergy":0,"consumeenergy":0,"feedinpowerM2":0,"soc":0,"peps1":0,"peps2":0,"peps3":0,"inverterType":"4","inverterStatus":"102","uploadTime":"2022-03-11 16:57:20","batPower":0,"powerdc1":173,"powerdc2":0,"powerdc3":null,"powerdc4":null}
1 Like

I have recopied the url and it now works for me as well.

Me apologies for your time.
I have learnt from my mistake

Best regards

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