How to send array in nodejs http request

The PHP API request array as input. Based on the example it is also need to be convert by http_build_query. The http_build_query PHP function create a following sting: “order_ids%5B0%5D=123&order_ids%5B1%5D=456&order_ids%5B2%5D=789”

$curl_parameters['order_ids'] = array(123,456,789);

$curl_options = array(
    CURLOPT_POSTFIELDS => http_build_query($curl_parameters),

The first part of nodejs script:

const order_ids = { "order_ids": [123,456,789] }  
const order = httpBuildQuery(order_ids)   //This line create a same format like in PHP script. It is an NPM package.

const options = {
    mehod: 'POST',                                             
    auth: username + ":" + password,

The https request part looks like this but I alawys got error message. Looks like I am not sending the array in a right way.

const req = http.request(url, options, (res) => {                   
    res.on('data', (d) => {                                 


I got a following error message :
//error=> implode(): Invalid arguments passed.{“result”:“success”,“event”:“getawb”,“msg”:}

What is wrong with my code? How should I send array in a right way?

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