AnsweredAssumed Answered

POST request becomes GET request after authentication using

Question asked by ajansen on Jul 18, 2007
Latest reply on Dec 17, 2007 by kevinr
I am using web scripts to create content in Alfresco:

<webscript>
  <shortname>Content Create Sample</shortname>
  <description>Sample</description>
  <url>/test/createcontent</url>
  <format default="html">extension</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
</webscript>

This is working OK, when a user is not logged the basic browser prompt is hown and the script continues.
Now I  customized the login to use the webclient instead of basic authentication in the web.xml:

   <servlet>
      <servlet-name>apiServlet</servlet-name>
      <servlet-class>org.alfresco.web.scripts.WebScriptServlet</servlet-class>
      <init-param>
         <param-name>authenticator</param-name>
         <param-value>webscripts.authenticator.webclient</param-value>
      </init-param>
   </servlet>

What happens when a user is not logged in the standard alfresco login page is displayed but the web script is not running correctly after successful login. From the log I retrieved this error:

13:45:05,044 DEBUG [org.alfresco.web.scripts.WebScriptServlet] Processing request (POST) http://localhost:8080/alfresco/service/test/createcontent
13:45:05,054 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Processing script url (POST) /test/createcontent
13:45:05,054 DEBUG [org.alfresco.web.scripts.DeclarativeWebScriptRegistry] Web Script index lookup for uri /test/createcontent took 0ms
13:45:05,054 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Agent: Firefox
13:45:05,054 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Format style: extension, Default format: html
13:45:05,054 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Invoking Web Script org/alfresco/repository/poc/createcontent.post (unauthenticated)
13:45:05,064 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Begin transaction: required
13:45:05,064 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Current authentication: unauthenticated
13:45:05,064 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Authentication required: user
13:45:05,064 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Guest login: false
13:45:05,064 DEBUG [org.alfresco.web.scripts.WebClientAuthenticator] Alfresco ticket provided: false
13:45:05,064 DEBUG [org.alfresco.web.scripts.WebClientAuthenticator] Authenticating session
13:45:05,084 DEBUG [org.alfresco.web.scripts.WebClientAuthenticator] Redirecting to Alfresco Login
13:45:05,084 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Authentication reset: unauthenticated
13:45:05,084 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] End transaction: required
13:45:05,084 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Web Script org/alfresco/repository/poc/createcontent.post executed in 30ms
13:45:05,084 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Processed script url (POST) /test/createcontent in 40ms
13:45:11,974 DEBUG [org.alfresco.web.scripts.WebScriptServlet] Processing request (GET) http://localhost:8080/alfresco/service/test/createcontent
13:45:11,974 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Processing script url (GET) /test/createcontent
13:45:11,974 DEBUG [org.alfresco.web.scripts.DeclarativeWebScriptRegistry] Web Script index lookup for uri /test/createcontent took 0ms
13:45:11,974 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Script url /test/createcontent does not support the method GET
13:45:12,584 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Force success status header in response: false
13:45:12,584 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Sending status 405 (Template: /status.ftl)
13:45:12,584 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Rendering response: content type=text/html
13:45:12,655 DEBUG [org.alfresco.web.scripts.WebScriptRuntime] Processed script url (GET) /test/createcontent in 681ms

Is this a bug or am I missing something ?

Outcomes