HTTP Request without Success

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

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
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 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 :wink:

The cookbook should be able to help you out.

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';
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?

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

Could you try to put this in a function node:

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.

  • 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 :wink:

Thank you for your help!

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