Showing results for 
Search instead for 
Did you mean: 

How to make XSJS service to return .

0 Kudos

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;
			"name" :
$.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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos


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.