<!DOCTYPE HTML PUBLIC error accessing remote API

Good day the community,

I am trying to post trade from Node Red to an API platform interface. My flow is working well with their demo interface, however when it comes to send trade to the real interface, my flow is not working anymore, I get the following message on the node red debug window :

I cannot find the solution, although I have carefully followed all the information on the website API section : https://www.bitmex.com/app/apiKeysUsage
I called the support to know if I need to tick a box or if I need any approval. They told me I should be able to post trade in a normal way, nothing to tick or no approval requested.

Here is my "working" demo account

[{"id":"91a60efa.22e16","type":"function","z":"384daa3d.6b3f96","name":"Generate Payload for Auth","func":"const apiKey = \"KXj6hjkDY6zcJ5gHaS3TkIlR\";\nconst apiSecret = \"KU1ZWDw9YIOZwcF-9MPow1XFu5fDJjFZyzI5KBGnTYZVgEpB\";\n\nconst verb = 'POST';\nconst path = '/api/v1/order';\nconst expires = Math.round(new Date().getTime() / 1000) + 120; // 2 min in the future\nconst data = {\n    symbol: 'XBTUSD',\n    orderQty:6,\n    ordType: 'Market',\n    side: flow.get(\"Direction\")\n};\nconst postBody = JSON.stringify(data);\n\nmsg.payload = verb + path + expires + postBody\nmsg.inputData = {\n    verb: verb,\n    path: path,\n    expires: expires,\n    data: data,\n    postBody: postBody\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":1060,"y":1500,"wires":[["e1d7bb80.4b9878"]]},{"id":"c78b7024.5cbfb","type":"function","z":"384daa3d.6b3f96","name":"API Data","func":"const apiKey = \"KXj6hjkDY6zcJ5gHaS3TkIlR\";\nconst apiSecret = \"KU1ZWDw9YIOZwcF-9MPow1XFu5fDJjFZyzI5KBGnTYZVgEpB\";\nconst signature = msg.payload;\nconst inputData = msg.inputData;\n\nmsg.payload = inputData.postBody;\n\nmsg.headers = {\n 'content-type' : 'application/json',\n 'Accept': 'application/json',\n 'X-Requested-With': 'XMLHttpRequest',\n 'api-expires': inputData.expires,\n 'api-key': apiKey,\n 'api-signature': signature\n};\n\nreturn msg;\n","outputs":1,"noerr":0,"x":1220,"y":1600,"wires":[["e64a6360.e822d"]]},{"id":"e64a6360.e822d","type":"http request","z":"384daa3d.6b3f96","name":"post Order to BitMEX","method":"POST","ret":"txt","url":"https://testnet.bitmex.com/api/v1/order","tls":"","x":1160,"y":1720,"wires":[["b82ce77f.aa4be8"]]},{"id":"e1d7bb80.4b9878","type":"hmac","z":"384daa3d.6b3f96","name":"Signature","algorithm":"HmacSHA256","key":"KU1ZWDw9YIOZwcF-9MPow1XFu5fDJjFZyzI5KBGnTYZVgEpB","x":1000,"y":1600,"wires":[["c78b7024.5cbfb"]]},{"id":"b82ce77f.aa4be8","type":"debug","z":"384daa3d.6b3f96","name":"Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1400,"y":1720,"wires":[]}]
```

Here is my "not working" real account 

`````[{"id":"eae5990a.09e298","type":"function","z":"384daa3d.6b3f96","name":"Generate Payload for Auth","func":"const apiKey = \"5Nr_wmSsPad4RODsvosndnkL\";\nconst apiSecret = \"K1NEUBa5lfgZIsuGEbw6Cdf8de5UFGWRwz-UQ7gaYjN9e5cg\";\n\nconst verb = 'POST';\nconst path = '/api/v1/order';\nconst expires = Math.round(new Date().getTime() / 1000) + 120; // 2 min in the future\nconst data = {\n    symbol: 'XBTUSD',\n    orderQty:1,\n    ordType: 'Market',\n    side: flow.get(\"Direction\")\n};\nconst postBody = JSON.stringify(data);\n\nmsg.payload = verb + path + expires + postBody\nmsg.inputData = {\n    verb: verb,\n    path: path,\n    expires: expires,\n    data: data,\n    postBody: postBody\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":1060,"y":1200,"wires":[["9beefa55.0bd458"]]},{"id":"ff105181.2d4b","type":"function","z":"384daa3d.6b3f96","name":"API Data","func":"const apiKey = \"5Nr_wmSsPad4RODsvosndnkL\";\nconst apiSecret = \"K1NEUBa5lfgZIsuGEbw6Cdf8de5UFGWRwz-UQ7gaYjN9e5cg\";\nconst signature = msg.payload;\nconst inputData = msg.inputData;\n\nmsg.payload = inputData.postBody;\n\nmsg.headers = {\n 'content-type' : 'application/json',\n 'Accept': 'application/json',\n 'X-Requested-With': 'XMLHttpRequest',\n 'api-expires': inputData.expires,\n 'api-key': apiKey,\n 'api-signature': signature\n};\n\nreturn msg;\n","outputs":1,"noerr":0,"x":1220,"y":1300,"wires":[["5b8f611c.3bfb3"]]},{"id":"4ead12b7.62f4dc","type":"debug","z":"384daa3d.6b3f96","name":"Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1400,"y":1420,"wires":[]},{"id":"9beefa55.0bd458","type":"hmac","z":"384daa3d.6b3f96","name":"Signature","algorithm":"HmacSHA256","key":"K1NEUBa5lfgZIsuGEbw6Cdf8de5UFGWRwz-UQ7gaYjN9e5cg","x":1000,"y":1300,"wires":[["ff105181.2d4b"]]},{"id":"5b8f611c.3bfb3","type":"http request","z":"384daa3d.6b3f96","name":"post Order to BitMEX","method":"POST","ret":"txt","url":"https://bitmex.com/api/v1/order","tls":"","x":1180,"y":1420,"wires":[["4ead12b7.62f4dc"]]}]
```

Thank you very much for your precious help. Appreciated.

It is a cloudflare error, if you google bitmex request could not be satisfied you will find an answer.

solution:
Use https://www.bitmex.com instead of https://bitmex.com

try:
"url": "https://www.bitmex.com/api/v1/order",

(remove your "real" account flow from your post and/or change api keys.)

1 Like

Thank you very much bakman2, this is the solution, it works now! :slight_smile:
(I had previously disabled and changed the api keys of real account)