Michael Williams
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.
I receive the following response if the view name provided does not exist:
Can I redesign the service so I can control the error response?
Thanks in advance.
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>
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"
}
Can I redesign the service so I can control the error response?
Thanks in advance.
Redesign? In what way? You could move to a CustomRESTService, entirely written in Java, if that's what you mean.
ASKER
What I mean is....
Can I control the failure responses via the existing service?
Can I control the failure responses via the existing service?
ASKER
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”
}
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.
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.
ASKER
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”
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I like the approach. I will try that when I get off work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Trying to identify whether or not the view name passed is valid worked.