# Problems with hitting your API using Node.js

**URL:** <https://meta.discourse.org/t/problems-with-hitting-your-api-using-node-js/146242>\
**Category:** Development\
**Created:** [March 31, 2020, 8:38am UTC](https://meta.discourse.org/t/problems-with-hitting-your-api-using-node-js/146242 "2020-03-31T08:38:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Konrad\_Sopala](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/konrad_sopala/32/167014_2.png) [@Konrad\_Sopala](https://meta.discourse.org/u/Konrad_Sopala)\
**Post date:** [March 31, 2020, 11:59am UTC](https://meta.discourse.org/t/problems-with-hitting-your-api-using-node-js/146242/2 "2020-03-31T11:59:43Z")

</div>

Figured it out. Here’s the solution code:

```plaintext

const http = require('https');

const options = {
  hostname: 'community.myCompanyName.com',
  path: '/admin/plugins/explorer/queries/73/run',
  method: 'POST',
  headers: {
    accept: 'application/json',
    'Content-Type': 'multipart/form-data',
    'Api-Key': '<api_key>',
    'Api-Username': '<my_username>'
  }
};

var response = 1;

const req = http.request(options, (res) => {
  console.log(`statusCode: ${res.statusCode}`);
  response = res;

  res.on('data', (d) => {
    process.stdout.write(d);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.end();

var parsed_response = JSON.parse(response);
console.log(parsed_response);

```

---

_[View the full topic](https://meta.discourse.org/t/problems-with-hitting-your-api-using-node-js/146242)._
