# HTTP Request without Success

**URL:** <https://discourse.nodered.org/t/http-request-without-success/60220>\
**Category:** General\
**Tags:** http-request\
**Created:** [23 March 2022 05:40 UTC](https://discourse.nodered.org/t/http-request-without-success/60220 "2022-03-23T05:40:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Triark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/triark/32/58932_2.png) [@Triark](https://discourse.nodered.org/u/Triark)\
**Post date:** [23 March 2022 05:40 UTC](https://discourse.nodered.org/t/http-request-without-success/60220/1 "2022-03-23T05:40:21Z")

</div>

Hello,

I'm trying to make the same request as this one, but with a CHANGE or FUNCTION node, and I can't get it... the server responds that it doesn't receive the USERNAME or the LEVEL...

```auto
NODEJS example:

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://http-api.d7networks.com/send?username=xxxxxx&password=xxxxxx&dlr-method=POST
   &dlr-url=https://4ba60af1.ngrok.io/receive&dlr=yes&dlr-level=3&from=smsinfo
   &content=This is the sample content sent to test &to=3333333',
  'headers': {
  },
  formData: {

  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

I have tried with msg.payload.dlr with msg.dlr and nothing...  
This is my Change node:

SET msg.dlr-method = POST  
SET msg.dlr-url = [https://4ba60af1.ngrok.io/receive](https://4ba60af1.ngrok.io/receive)  
SET msg.dlr-level = 3  
SET msg.dlr = YES  
SET msg.payload.username = (I also tried without payload: msg.username)  
SET msg.pauload.password = (I also tried without payload)  
SET msg.payload.from = (I also tried without payload)  
SET msg.payload.to = (I also tried without payload)  
SET msg.payload.content = (I also tried without payload)

No success so far...

If I program it in an HTTP Request Node with POST with this string:  
[https://http-api.d7networks.com/send?username=xxxxxxx&password=xxxxxxx&dlr-url=https://4ba60af1.ngrok.io/receive&dlr=yes&dlr-level=3&from=smsinfo&content=This](https://http-api.d7networks.com/send?username=xxxxxxx&password=xxxxxxx&dlr-url=https://4ba60af1.ngrok.io/receive&dlr=yes&dlr-level=3&from=smsinfo&content=This) is the sample content sent to test&to =33333333

It works.

What I need is that these input parameters can be loaded independently: CONTENT, TO, FROM, USERNAME, PASSWORD, etc.

Can you help me (I'm learning this wonderful tool called Node-Red 😉

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [23 March 2022 06:01 UTC](https://discourse.nodered.org/t/http-request-without-success/60220/2 "2022-03-23T06:01:51Z")

</div>

The [cookbook should be able](https://cookbook.nodered.org/http/set-request-header) to help you out.

---

<div class="post-metadata">

**Author:** ![Triark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/triark/32/58932_2.png) [@Triark](https://discourse.nodered.org/u/Triark)\
**Post date:** [23 March 2022 15:48 UTC](https://discourse.nodered.org/t/http-request-without-success/60220/3 "2022-03-23T15:48:09Z")

</div>

Hello,

I was tried without success too...

This is my function node:

msg.payload = "";  
msg.headers = {};  
msg.headers['username'] = 'xxxxxx';  
msg.headers['password'] = 'xxxxxx';  
msg.headers['dlr-url']='[https://4ba60af1.ngrok.io/receive](https://4ba60af1.ngrok.io/receive)';  
msg.headers['dlr']='yes';  
msg.headers['dlr-level']='3';  
msg.headers['from']='smsinfo';  
msg.headers['content']='message';  
msg.headers['to']='3333333'  
return msg;

The error is the same : Error "Mandatory argument [username] is not found."

Any comment?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [23 March 2022 16:45 UTC](https://discourse.nodered.org/t/http-request-without-success/60220/4 "2022-03-23T16:45:04Z")

</div>

It looks like a GET request which is send as a post.

Could you try to put this in a function node:

```auto
let username = "myusername" // or let username = msg.payload.username etc
let password = "mypassword"
let content = "my content"
let to = "333333"
let from = "smsinfo"

let url = `https://http-api.d7networks.com/send?username=${username}&password=${password}&dlr-url=https://4ba60af1.ngrok.io/receive&dlr=yes&dlr-level=3&from=${from}&content=${content}&to=${to}`
return msg;

```

Attach it to a http-request node, set it to POST.

---

<div class="post-metadata">

**Author:** ![Triark](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/triark/32/58932_2.png) [@Triark](https://discourse.nodered.org/u/Triark)\
**Post date:** [23 March 2022 18:14 UTC](https://discourse.nodered.org/t/http-request-without-success/60220/5 "2022-03-23T18:14:22Z")

</div>

- In 1st request (sending let username = "username" the error is the same:

Error "Mandatory argument [username] is not found."

- In 2nd test, sending like this:  
..  
let username = msg.payload.username  
let password = msg.payload.password  
let content = msg.payload.content  
let to = msg.payload.to  
let from = msg.payload.from  
let url = `https://http-api.d7networks.com/send?username=${username}&password=${password}&dlr-url=https://4ba60af1.ngrok.io/receive&dlr=yes&dlr-level=3&from=${from}&content=${content}&to=${to}`  
**msg.url = url**  
return msg;  
..  
Is working 😉

Thank you for your help!

---

<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:** [6 April 2022 18:15 UTC](https://discourse.nodered.org/t/http-request-without-success/60220/6 "2022-04-06T18:15:17Z")

</div>

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