留言板
REST web service response code
Hello,
I created a portlet which have some function which are available as REST web services (see the "writing the remote service class" documentation).
Everything works fine. However, Liferay doesn't seem to include a solution to set the code which is returned in the HTTP response. A REST API should return some specific status code. Instead the Liferay web service always return the OK : 200 status code even when the request can not be proceeded.
For example running the following request :
https://myportal.com/api/secure/jsonws/announcementsentry/get-entry/entry-id/1
Where entryId is an id which doesn't exist, return :
Status code : 200 OK
Response body:
{
"exception": "com.liferay.portlet.announcements.NoSuchEntryException: No AnnouncementsEntry exists with the primary key 1"
}
A better solution should return a 404 Not found status code.
Actually, I don't really care about the web service already defined. I would like for the new web services I build to be able to set the response code.
Any solution to achieve this goal?
I created a portlet which have some function which are available as REST web services (see the "writing the remote service class" documentation).
Everything works fine. However, Liferay doesn't seem to include a solution to set the code which is returned in the HTTP response. A REST API should return some specific status code. Instead the Liferay web service always return the OK : 200 status code even when the request can not be proceeded.
For example running the following request :
https://myportal.com/api/secure/jsonws/announcementsentry/get-entry/entry-id/1
Where entryId is an id which doesn't exist, return :
Status code : 200 OK
Response body:
{
"exception": "com.liferay.portlet.announcements.NoSuchEntryException: No AnnouncementsEntry exists with the primary key 1"
}
A better solution should return a 404 Not found status code.
Actually, I don't really care about the web service already defined. I would like for the new web services I build to be able to set the response code.
Any solution to achieve this goal?
Nicolas Forney,修改在10 年前。
RE: REST web service response code
Junior Member 帖子: 78 加入日期: 11-5-23 最近的帖子
Nobody ?
Muhammed Shafeek V,修改在6 年前。
RE: REST web service response code
Regular Member 帖子: 140 加入日期: 13-7-22 最近的帖子
Hi Nicolas,
Did you get the soulution ? Please share
Did you get the soulution ? Please share