Link to home
Start Free TrialLog in
Avatar of Michael Williams
Michael WilliamsFlag for United States of America

asked on

Xpage viewJsonService REST Service

First and foremost, I am new to xpages.

I have a xpage REST Service that consumes a View Name URL parameter so I can have one service to retrieve any supplied view name.

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
	xmlns:xe="http://www.ibm.com/xsp/coreex">
	
	(JSON) - View Column - Pass View Name
	<xp:br></xp:br>
	<xe:restService id="restService1" pathInfo="GetViewColumns">
		<xe:this.service>
			<xe:viewJsonService systemColumns="0" defaultColumns="true" compact="true" count="1000">
				<xe:this.viewName><![CDATA[#{javascript:param.get("ViewName");}]]></xe:this.viewName>
			</xe:viewJsonService>
		</xe:this.service>
	</xe:restService>
</xp:view>

Open in new window


I receive the following response if the view name provided does not exist:

{
    "code": 400,
    "text": "Bad Request",
    "message": "Unknown view VIEWNAME in database Sample.nsf",
    "type": "text",
    "data": "com.ibm.domino.services.ServiceException: BLAH BLAH BLAH"
}

Open in new window


Can I redesign the service so I can control the error response?

Thanks in advance.
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Redesign? In what way? You could move to a CustomRESTService, entirely written in Java, if that's what you mean.
Avatar of Michael Williams

ASKER

What I mean is....

Can I control the failure responses via the existing service?
Additional info....

Standard failure is an error.

Are you able to control the failure response? Is there a way to have the response send back valid custom JSON?

Example:
{
“success”: false;
“response”: “Invalid data or view”
}
Possibly... Could you try with a Display Error control? I used to have great difficulty in understanding and using this type of control myself.

Where do you receive the response? Client side? In that case I suppose something can be done using the onError return of the event handler.
I am using Postman to connect to the Xpage REST Service.

The response to the Postman client is error text instead of a JSON response. I would like to customize the response (Valid JSON).

Example:
{
“success”: false;
“response”: “Invalid data or view”
}
SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I like the approach. I will try that when I get off work.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Trying to identify whether or not the view name passed is valid worked.