Skip to Content
0
Feb 20, 2017 at 12:33 PM

How to make XSJS service to return .

710 Views

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.