on 02-20-2017 12:33 PM
Hello Experts,
I have a requirement to create an XSJS service which should have both
<Content-Type: application/json> and <Accept: application/json>.
I have a sample code below, am bit confused:
var ReqBody = $.request.body.asString();
ReqBody = JSON.parse(ReqBody);
$.response.status = $.net.http.OK;
$.response.setBody(JSON.stringify(
{
"name" : ReqBody.id
}
));
$.response.contentType = "application/json";
$.response.headers.set("Access-Control-Allow-Origin", "*");
I am getting the response in json format, but am not sure if the Accept is in Json or not.
Request you to please guide me.
Hi,
You may like the sender (the caller of your XSJS) to pass a parameter which specifies whether the output needed is in the JSON or in text. Based on the input you can set the content type while returning the object to response.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.