POST Webscript

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

POST Webscript

I wrote  a post webscript :

JAVA Controller :

protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status) {

String id = (String) req.getParameter("id");
String username = (String) req.getParameter("username");
System.out.println(username);
System.out.println(id);

//OTHER STUFF

model.put("id", id);
model.put("username", username);

return model;
}
Descriptor :
<webscript>
<shortname>Change status</shortname>
<description>Change status</description>
<url>/pfe/status?id={id}&amp;username={username}</url>
<format default="json">extension</format>
<authentication runas="admin">guest</authentication>
<transaction>required</transaction>
</webscript>

Template
{"ChangeStatus" :
{
"id" : "${id}",
"username" : "${username}"
}
}

And I'm always getting username = null and id = null ?

2 Replies
Highlighted
Established Member II

Re: POST Webscript

Is your controller in java executed?

Are you sure that the id of your backed web script bean match the package, name an HTTP Method of the webscript definition?

To ensure that you are configured correctly the Java Backed Web Script you can access the info page of your web script in the Alfresco Webscript Home and check that the property calledl implementation is pointing to your class.

Highlighted
Active Member

Re: POST Webscript

The problem was in the descriptor, in the url tag
It needs to be like this <url>/pfe/status?id={id?}&amp;username={username?}</url> with the question mark.
Thanks.