# Openweather problem - sorry folks. I goofed

**URL:** <https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137>\
**Category:** General\
**Created:** [10 April 2024 20:26 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137 "2024-04-10T20:26:18Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2024 20:26 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/1 "2024-04-10T20:26:18Z")

</div>

See my other thread:

> [@Open-weather errors. What is happening?](https://discourse.nodered.org/t/open-weather-errors-what-is-happening/87112):
>
> I use open-weather a lot and just recently it is throwing weird errors at me. As we are going into winter, (ok, Autumn) it is raining more and more. For now I am doing a series of weather gets from midnight to mid day to see how much rain has fallen. (Each hour, there about) This shows the error (kind of) and the time. 02:00 and The API call returned invalid JSON This is a list of attempts to see what is the problem: Yeah, not perfect as the object…

Alas I (we) got distracted from the real problem.

At the start I was getting messages saying the node was giving non-valid JSON messages.

That digressed into the `link-call` not returning and I accidentally accepted that as the solution.

But it didn't address the original problem.

 ![Screenshot from 2024-04-11 06-18-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1cb05dfa9768a465650c50aa1d4c5276ddf04f4f.png)

The node was _called_ at 00:00, 01:00, 02:00, 03:00. 04:00, 05:00, and 06:00.

# Why did it fail with the 01:00 call and `The API call returned invalid JSON`?

But only at the one time today?

---

<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:** [10 April 2024 20:35 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/2 "2024-04-10T20:35:20Z")

</div>

Is this a http request node call?

If you add a debug node after it, what is actually returned when good and when invalid json?

Is the http request node set to return a parsed JS object?

If so could the return not a JSON when error is thrown?

If you set to output a utf8 string, can you then check statusCode?

If statusCode is 200, could you then direct to a JSON node, and if not 200 handle the return differently?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2024 20:38 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/3 "2024-04-10T20:38:43Z")

</div>

Ummmm........ To be honest, I am not sure.

I send a _message_ into the node and get back a JSON message that contains the weather at this point in time - and other stuff.

99.9% of the time it works.

Recently it has started to be difficult and I get these messages.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2024 20:43 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/4 "2024-04-10T20:43:01Z")

</div>

This is what I am seeing - kind of again - and note how the 01:00 message is missing.

 ![Screenshot from 2024-04-11 06-34-43](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/4044ef6a1fa7d4ac8e907c50f3c67196b36d454b.jpeg)

Yes, there is a slight problem with how I am seeing the messages in that the `objects` aren't expanded and therefore readable.

But that the error happened at 01:00 and the 01:00 message is _missing_ I'd say there is some relationship there.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2024 20:46 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/5 "2024-04-10T20:46:31Z")

</div>

And... (sorry)

This seems to only happen at night.

If I send messages into the node at other times it works.

See new screenshot at the top all the crossed out stuff.  
That was me testing it last night.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2024 20:59 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/6 "2024-04-10T20:59:03Z")

</div>

(Dug around and looked at some logs.)

EDITED to remove other things that happened.

This is an extract from my error log WRT this node.

```auto
===================
When 2024-03-08 02:00:15
Who ERROR_REPORT/BedPi/PlantWateringControl
Where 8b3d501f37079bdf
What The API call returned invalid JSON
===================

===================
When 2024-04-08 08:00:19
Who ERROR_REPORT/BedPi/PlantWateringControl
Where 8b3d501f37079bdf
What The API call returned invalid JSON
===================

===================
When 2024-04-08 12:00:35
Who ERROR_REPORT/BedPi/PlantWateringControl
Where 8b3d501f37079bdf
What The API call returned invalid JSON
===================

===================
When 2024-04-10 02:00:22
Who ERROR_REPORT/BedPi/PlantWateringControl
Where 8b3d501f37079bdf
What The API call returned invalid JSON
===================

===================
When 2024-04-10 10:00:10
Who ERROR_REPORT/BedPi/PlantWateringControl
Where 8b3d501f37079bdf
What The API call returned invalid JSON
===================

===================
When 2024-04-10 11:00:11
Who ERROR_REPORT/BedPi/PlantWateringControl
Where 8b3d501f37079bdf
What The API call returned invalid JSON
===================

===================
When 2024-04-11 01:00:11
Who ERROR_REPORT/BedPi/PlantWateringControl
Where 8b3d501f37079bdf
What The API call returned invalid JSON
===================

```

It seems to have started on 8 March and is happening at different times.

Alas all/most of them when I am not at home.  
Not that that will really mean much.

I'm not sure when I started but I call the node every hour from Mid-night to 12:00 (within that minute at least.) Done from a `trigger` node to re-send every hour. So if it gets the message a bit after THE EXACT hour, it will show. (Not a big deal)

I may switch it to `on time` and see what happens just to test/establish ..... _something_.

I'm not sure it will really help as the node isn't failing constantly, and when I was testing things last night it was working with every inject I did.

## Recent edits to flow.

From what I can remember I have created a new message going into the `openweather` node very recently as I saw some weird messages going into it.  
I HAD a `link-call` used to call this part of the code but have since replaced it with `link-out` and `link-in` nodes.  
It was pointed out if I corrupted the message, it wouldn't/couldn't be returned as it didn't know it's origin.  
Edited/tidied up some code in nodes DOWNSTREAM from the node, so I'm not sure they really have any change on that node's 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:** [10 April 2024 21:04 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/7 "2024-04-10T21:04:40Z")

</div>

Screenshots with hundreds of nodes and debug messages with next to no info are not great for diagnosing issues.

As mentioned above, set the a http node with the request to out put a utf8 string and set a debug to output complete message object. Then capture a good return and a bad return (invalid json). We can then compare the returns and offer fixes.

I asked questions in previous response, the answer to these question would help formulate a possible issue and solution.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2024 21:09 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/8 "2024-04-10T21:09:28Z")

</div>

> [@E1cid](#):
>
> set the a http node

Sorry, which `http node`?

---

<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:** [10 April 2024 21:17 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/9 "2024-04-10T21:17:43Z")

</div>

Well i did ask questions , but got no answers to them, so i assumed (no i'm a ass silly me). I see by the edit of the last post from you, that you now mention openweather node, which when i used it can sometimes have socket timeout issues, so i moved to http requests.

We would still need to see the responses from the open weather node then to ascertain any issue.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2024 21:22 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/10 "2024-04-10T21:22:17Z")

</div>

The _node_ is `openweather`.

> [@E1cid](#):
>
> Is this a http request node call?
> 
> If you add a debug node after it, what is actually returned when good and when invalid json?
> 
> Is the http request node set to return a parsed JS object?
> 
> If so could the return not a JSON when error is thrown?
> 
> If you set to output a utf8 string, can you then check statusCode?
> 
> If statusCode is 200, could you then direct to a JSON node, and if not 200 handle the return differently?

I DON'T KNOW.

Is that a good enough answer.

I put in the location I want the weather for, the API KEY,

 ![Screenshot from 2024-04-11 07-21-16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/80d90769293f55528928f566c3e0f1a720fb36cf.png)

I can't see any of those options.

I have since added a log to file bit of code so I can see what is logged tomorrow.  
But until then, I am not able to just produce the error as it happens when IT wants to.

---

<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:** [9 July 2024 21:23 UTC](https://discourse.nodered.org/t/openweather-problem-sorry-folks-i-goofed/87137/11 "2024-07-09T21:23:09Z")

</div>

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