Mehul
Mehul

Reputation: 178

How to set custom HTTP code in MarkLogic REST function

In MarkLogic 9, I'm using a custom SJS service with POST method where I do some basic search & validation giving a custom result for errors (Not using fn.error because of requirements).

The error that I return in POSTMAN is a simple JSON like this:

{
"code":400,
"message":"Bad request",
"reason":"string"
}

The HTTP code-message header above the response in POSTMAN shows "200 OK" even after using xdmp.setResponseCode(400, "Bad request");

How to set the HTTP code to a manual number/message while following the standard protocols?

Upvotes: 0

Views: 155

Answers (1)

ehennum
ehennum

Reputation: 7335

It depends whether the custom SJS service is

Hoping that helps,

Upvotes: 2

Related Questions