Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Cannot set 'HTTP/1.1 200 OK' in REST Service Response Header

SA-67945

Summary



Unable to generate Service REST response with status as 'HTTP/1.1 200 OK' in the REST Service Response Header.


Error Messages



[ttp-nio-8080-exec-25] [STANDARD] [ ] [OrigApp:01.01.01] (internal.services.ServiceAPI) ERROR ip-127-0-0-1.your_domain.abc.com|127.0.0.1 |Rest|poc|v1|solacepocf3dd60c6825baaa1c341db4b9917ff8b|A65NTMW9HESUK8ZGDBAWJJI65XBEJZXB2 - Rest service [poc][v1][solacepocf3dd60c6825baaa1c341db4b9917ff8b] failed:For input string: "200 OK": java.lang.NumberFormatException: For input string: "200 OK"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615)
at com.pega.pegarules.integration.engine.internal.services.ServiceAPI.configureResponse(ServiceAPI.java:3016)
at com.pega.pegarules.integration.engine.internal.services.ServiceAPI.mapOutputData(ServiceAPI.java:2017)
at com.pega.pegarules.session.external.engineinterface.service.EngineAPI.activityExecutionEpilog(EngineAPI.java:593)
at com.pega.pegarules.session.external.engineinterface.service.EngineAPI.processRequestInner(EngineAPI.java:494)



Steps to Reproduce

  1. Create a simple REST Service.
  2. Set the Status Code as 200 OK.
  3. Invoke the service.


Root Cause



The NumberFormatException displays because the rule form only accepts numeric codes for the Status code field.  Adding a string such as 'OK' to the standard HTTP 200 code for any request is not allowed in the product. This is due to the application server.
Hence, there is no provision to set HTTP Status codes along with string messages such as '200 OK' or '201 Created' in the Service REST responses.


Resolution



Here's the explanation for the reported behavior:

Standard HTTP success status codes for Service REST requests or any other HTTP requests are set by javax.servlet.http.HttpServletResponse API.
The application invokes setStatus(int) with the relevant numeric status code. Adding a string such as 'OK' for 200 is not controlled in the product.

'HTTP/1.1 200 OK' or 'HTTP/1.1 200' depends on the servlet API version used by the user's application server.
The Tomcat version which provided the '200 OK' in HTTP responses is Apache Tomcat 8.0.53.



 

Published December 4, 2018 - Updated December 2, 2021

Was this useful?

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us