# Http request POST ==\> JSON-Parsing-Error

**URL:** <https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622>\
**Category:** General\
**Created:** [23 January 2021 18:59 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622 "2021-01-23T18:59:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![steyrblade](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@steyrblade](https://discourse.nodered.org/u/steyrblade)\
**Post date:** [23 January 2021 18:59 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622/1 "2021-01-23T18:59:39Z")

</div>

Hi there,

im trying to use an http request to send a notification to alexa via getnotifyme,  
but I always get "JSON-Parsing-Error" in debug.  
Basic authentication is set with the right API key and API secret.  
I tried it onyl with an payload with JSON: "message":"Alexa notification by Sascha"  
and with a function as the following and always get .  
If I leave out the API key and API secret I get "Unauthorized", so that I assume that the payload is wrong or something is missing.  
(If I use their website [https://www.getnotify.me/](https://www.getnotify.me/) directly via my browser it works, that means no problems at their connection to my Alexa)

```auto
msg.method = "POST"
msg.url = "https://api.getnotify.me/submit" ;
msg.headers = {
    "Content-Type": "application/json"
};
msg.payload = {
"message":"Alexa notification by Sascha"
};
return msg

```

**Instructions from [getnotify.me](http://getnotify.me):** ==\> attached  
Authentication: Basic (username = API key, password = API secret)  
Format: json  
Body: {"message":"your message here"}

---

<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:** [23 January 2021 20:16 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622/2 "2021-01-23T20:16:01Z")

</div>

How are you setting authorisation?  
what is http request node set to return?

---

<div class="post-metadata">

**Author:** ![steyrblade](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@steyrblade](https://discourse.nodered.org/u/steyrblade)\
**Post date:** [24 January 2021 19:11 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622/3 "2021-01-24T19:11:58Z")

</div>

![2021-01-24 20_09_27-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4edd1e03afdb62feae1c56a020460b18acbb9eff.png)  
and I also tried it in the payload via msg.payload.username & msg.payload.password is defined in the injection:

```auto
msg.method = "POST"
msg.url = "https://api.getnotify.me/submit" ;
msg.headers = {
    "Content-Type": "application/json"
};
msg.payload = {
"Authorization": 'Basic ' & msg.payload.username & ':' & msg.payload.password,
"message":"Alexa notification by Sascha"
};
return msg

```

and the request returns nothing:  
msg.payload : string[0]

---

<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:** [24 January 2021 19:26 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622/4 "2021-01-24T19:26:00Z")

</div>

```auto
msg.method = "POST"
msg.url = "https://api.getnotify.me/submit" ;
msg.headers = {
    "Content-Type": "application/json",
    "Authorization": "Basic " + msg.payload.username 
};
msg.payload = {
"message":"Alexa notification by Sascha"
};

```

The authorisation should be in the headers.

Also try returning a utf8 string.

---

<div class="post-metadata">

**Author:** ![steyrblade](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@steyrblade](https://discourse.nodered.org/u/steyrblade)\
**Post date:** [24 January 2021 19:42 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622/5 "2021-01-24T19:42:12Z")

</div>

I dont know why, but it works now without changing anything (but I still get JSON-Parsing-Error)

---

<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:** [24 January 2021 19:45 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622/6 "2021-01-24T19:45:12Z")

</div>

Show the output of a debug node after the http request node.  
It will show what is being returned. As said before, set the http node to return a string, as i suspect that is what is being returned.

---

<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 2021 19:45 UTC](https://discourse.nodered.org/t/http-request-post-json-parsing-error/39622/7 "2021-03-25T19:45:28Z")

</div>

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