The Korengali Kore The Korengali Kore - 8 days ago 6
Node.js Question

Parenthesis in Node Express POST Route not found

I am mocking a POST route in Express for testing MS XRM.

Working Route:

http://localhost:3000/api/data/v8.0/something

app.post('/api/data/v8.0/something', function (req, res) {
res.send({data:'1234A'});
});


Failing Route:

http://localhost:3000/api/data/v8.0/something(ABC)/somethingelse

app.post('/api/data/v8.0/something(ABC)/somethingelse', function (req, res) {
res.send({data:'1234A'});
});

Answer

Parentheses in route paths have special meaning, but it looks like you can escape them like this:

app.post('/api/data/v8.0/something[(]ABC[)]/somethingelse', function (req, res) {
  res.send({data:'1234A'});
});
Comments