# Unable to retrieve data from http request

**URL:** <https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330>\
**Category:** General\
**Tags:** http-request\
**Created:** [3 March 2022 20:21 UTC](https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330 "2022-03-03T20:21:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![OllyB](https://avatars.discourse-cdn.com/v4/letter/o/6de8d8/32.png) [@OllyB](https://discourse.nodered.org/u/OllyB)\
**Post date:** [3 March 2022 20:21 UTC](https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330/1 "2022-03-03T20:21:38Z")

</div>

Hello all,  
I am trying to retrieve data from an xml file on an ethernet-connected energy meter on my local network.  
When I connect to the meter using a browser (Chrome) at 192.168.1.60/readings.xml and use the Developer window to look at the content I see the following:

```auto
<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
<readings_instrument_values><![CDATA[<table class='parametersTable fullWidth'><tr class='tableRow'><td class='separatorCell' colspan='12'>REAL TIME</td></tr><tr class='tableRow'><td class='paramCell1'>V1N<div class='black'>=</div></td><td class='valueCell'><div class='numericalValue'>&nbsp;237.5</div>
// I've truncated this, suffice to say it's the data that I'm interested in
</readings_instrument_values>
</response>

```

The content also displays as a normal webpage with a browser-imposed title that reads:  
"This XML file does not appear to have any style information associated with it. The document tree is shown below."  
It then displays the entire content that is shown in the Developer window.

When I perform the same request using an http request node, I get the following payload as a string:

```auto
<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
<readings_instrument_values></readings_instrument_values>
</response>

```

...or in other words it is missing the useful data that I expected to see between \<readings\_instrument\_values\> and \</readings\_instrument\_values\>

Can anyone suggest what I should be doing to get the http request to bring all of the content over? Or a different method to retrieve the data?  
Any suggestions gratefully received.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [3 March 2022 22:09 UTC](https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330/2 "2022-03-03T22:09:43Z")

</div>

It's possible this might be a bug with the debug sidebar and it's hiding the `<![CDATA[...]>` block.

If you set the debug node to output to the console as well as the sidebar and then check the logs to see it the whole mesage is there.

---

<div class="post-metadata">

**Author:** ![OllyB](https://avatars.discourse-cdn.com/v4/letter/o/6de8d8/32.png) [@OllyB](https://discourse.nodered.org/u/OllyB)\
**Post date:** [4 March 2022 11:21 UTC](https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330/3 "2022-03-04T11:21:25Z")

</div>

Thanks for the reply.

I've just tried this and it has the same output to the console as it does to the debug sidebar.

Also the string length of msg.payload is 127 characters, so there doesn't appear to be any "hidden" content...

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [4 March 2022 13:15 UTC](https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330/4 "2022-03-04T13:15:42Z")

</div>

I would check the headers being sent by the browser, and try to emulate them by passing `msg.headers` into your `http request` node... it could be that a header like this:

```
Accept: text/xml

```

causes the device to send more info than a bare http request? I've also seen that some devices look at the client string as well. It's also possible that while using the browser you received some cookies that are being sent back with each request.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [4 March 2022 22:20 UTC](https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330/5 "2022-03-04T22:20:07Z")

</div>

And try fetching the page with `curl`

But the content does look strange, there should be no need to wrap the content in a `<[CDATA[` block of it's just more XML

---

<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 May 2022 22:20 UTC](https://discourse.nodered.org/t/unable-to-retrieve-data-from-http-request/59330/6 "2022-05-03T22:20:27Z")

</div>

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