Dear domino cognoscenti,
I've just written a simple xAgent using an xpage which works for GET requests but when I submit a POST request I get an Error 500 HTTP Web Server: Command Not Handled Exception
with the following detail CLFAD0384E: Page instance not found. The $$viewid ID was not present in a POST request
(thanks Per for the hint).
Here's the code. What am I doing wrong? Do xpages not handle POST requests by default? Do I have to enable this or something?
Thanks very much for your time!
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
<xp:this.resources>
</xp:this.resources>
<xp:this.afterRenderResponse>
<![CDATA[#{javascript:
var exCon = facesContext.getExternalContext();
var requestMethod = exCon.getRequest().getMethod();
var response = exCon.getResponse();
var writer = facesContext.getResponseWriter();
response.setContentType("text/plain");
response.setHeader("Cache-Control", "no-cache");
writer.write(requestMethod);
writer.endDocument();
}]]>
</xp:this.afterRenderResponse>
</xp:view>
Edited 16 October 2022 I've tried the following:
- Added
viewState="nostate"
toxp:view
. (thanks Mark for that) - Had no code in the
afterRenderResponse
other than logging - still get the same problem. - Used code in the
beforeRenderResponse
- same problem. - Tried the
restService
- same.
The only thing that appears to fix it is:
- Introduce a field called
$$viewid
and set this to the value '!!' or '!0!' or similar. - Use the FormData Web API on the browser to build the request body.
- Send it as
Content-Type:multipart/form-data
.
Sending it as plain text, application/json etc doesn't work. For some reason the xpage won't accept other encoding types.
Any ideas anyone?