# Beginner - get data from url API

**URL:** <https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725>\
**Category:** General\
**Created:** [11 March 2022 15:30 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725 "2022-03-11T15:30:29Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![RPG](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RPG](https://discourse.nodered.org/u/RPG)\
**Post date:** [11 March 2022 15:30 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/1 "2022-03-11T15:30:29Z")

</div>

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\*\*\*\*](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:57[node: solax](http://localhost:1880/#)msg.payload : string[746]

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 March 2022 15:33 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/2 "2022-03-11T15:33:25Z")

</div>

> [@RPG](#):
>
> HTTP Status 405 – Method Not Allowed

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

---

<div class="post-metadata">

**Author:** ![RPG](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RPG](https://discourse.nodered.org/u/RPG)\
**Post date:** [11 March 2022 15:55 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/3 "2022-03-11T15:55:31Z")

</div>

Yes I included valid token

here are exported flows

My apologies I am very new to this.

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

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 March 2022 15:59 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/4 "2022-03-11T15:59:59Z")

</div>

Do you have to log in before you get access?

If I try the URL with your token i get ...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c8bc01c37181f1d3634d81992677814a42639236.png)

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

---

<div class="post-metadata">

**Author:** ![RPG](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RPG](https://discourse.nodered.org/u/RPG)\
**Post date:** [11 March 2022 16:22 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/5 "2022-03-11T16:22:19Z")

</div>

I have just tried with incognito and it worked

---

<div class="post-metadata">

**Author:** ![RPG](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RPG](https://discourse.nodered.org/u/RPG)\
**Post date:** [11 March 2022 16:23 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/6 "2022-03-11T16:23:42Z")

</div>

it worked with no password requested

---

<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:** [11 March 2022 16:42 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/7 "2022-03-11T16:42:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RPG](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RPG](https://discourse.nodered.org/u/RPG)\
**Post date:** [11 March 2022 16:45 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/8 "2022-03-11T16:45:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RPG](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RPG](https://discourse.nodered.org/u/RPG)\
**Post date:** [11 March 2022 16:55 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/9 "2022-03-11T16:55:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 March 2022 16:59 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/10 "2022-03-11T16:59:13Z")

</div>

> [@RPG](#):
>
> In Chrome I did not have to give any authority/passwor

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](https://cookbook.nodered.org/http/set-request-header) for how to)

---

<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:** [11 March 2022 16:59 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/11 "2022-03-11T16:59:31Z")

</div>

remove the closing /  
this worked for me

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

```

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

```

---

<div class="post-metadata">

**Author:** ![RPG](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@RPG](https://discourse.nodered.org/u/RPG)\
**Post date:** [11 March 2022 17:03 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/12 "2022-03-11T17:03:14Z")

</div>

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

---

<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:** [25 March 2022 17:04 UTC](https://discourse.nodered.org/t/beginner-get-data-from-url-api/59725/13 "2022-03-25T17:04:03Z")

</div>

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