Question

Problems with Post request in nodejs (step Action Run Javascript)

  • 13 January 2022
  • 1 reply
  • 73 views

I have tried in many ways to be able to send the parameters via querystring using the Run JavaScript action, if I test it outside of Zapier it works fine for me, and even through Postman ... at the other end of this request, there is a page php that you get for get 2 parameters ... please, if someone has already gone through this, I ask for your guidance, thank you.

 

This is my zapier code:

const http = require('http');
const querystring = require('querystring');

const parameters = {
    url: inputData.varurl,
    fn: inputData.varfn
};

const post_data =  querystring.stringify(parameters);
const options = {
    host: "XXXXXXXX.cl",
    port: "80",
    path: "/test.php",
    method: "POST",
  headers: {
    'Content-Type': 'text/html; charset=UTF-8',
    'Connection': 'keep-alive'
  }
}

const request = http.request(options, (response) => {
    // console.log(response.statusCode);
});
request.write(post_data);
request.end();
  output = {request: request};


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 1
Badge +1

Hey there!

I'm Christian from Zapier's Platform Support team and I'll be happy to help with this.

Could you please provide a little more context around the nature of the issue that you’re seeing?

If you’re able to capture screenshots of any error messages or other troubles that you’re facing, I’ll be happy to take a closer look at this with you.

In the meantime, you might prefer to use Webhooks by Zapier to make the necessary POST request. If you need to URL encode some details for your querystring parameters, you could achieve this with a Text Formatter: URL encode step prior to the Webhooks step.

​I hope this helps to get you pointed in the right direction!