API and XML

Hello everyone,
I am currently creating an application (hikvision support). It needs to receive HTTP POST calls. I have declared the API in the manifest and created my api.js file. The problem is that I am receiving XML messages from the equipment, so the body is empty. Do you know how to fix this?

Best Regards

Looks like there’s a hardcoded limitation to only support JSON, so there’s not way to fix it with the built-in app API implementation and you may have to look into running a custom web server to accept these requests.

Thanks,
I have already tried this solution, but I cannot open a custom port (3000).

That shouldn’t be an problem, there are other apps that do the same. What error are you getting?

here my code

const http = require('http');

module.exports = class HikCamIsapiApp extends Homey.App {
   async onInit() {
      this.server = http.createServer(async (req, res) => {…});
      this.server.listen(3000, () => { this.log(‘Serveur HTTP lancé’); });
   }

When i call with curl
curl: (7) Failed to connect to XXXX port 3000 after 30 ms: Couldn’t connect to server

this.log(‘Serveur HTTP lancé’);

Invalid quote characters.

yes i know. It’s after copy/past.
In my homey log i have that:
2025-12-21T10:49:08.079Z [log] [HikCamIsapiApp] Serveur HTTP lancé
So it’s seem to be good

But the curl call faild

Sounds like a local issue, it’s working fine for me. Or are you using an external URL to connect to Homey?

no only local

Which homey are you on? Apparently there’s a firewall on 2023?

HP2023, and there is no firewall.

very strange. Can you send me your code please?

  async onInit() {
    this.server = http.createServer(async (req, res) => {
      this.log('received request');
      res.end('OK');
    });
    this.server.listen(3000, () => { this.log('Serveur HTTP lancé'); });
  }

very strange …

with homey app run → fail

with homey app install → Success ….

Who know why …?

Ohhh, right, you need to use this:

homey app run --remote

Without --remote, your app will not be running on your Homey at all, but instead in a local Docker container.

I’ve asked Athom many times to update the documentation to make this clear, but they simply don’t care.

OOOOOOOOOh thank you verrrrrry much :slight_smile:

1 Like