Hi Luis,
Thanks for your email.
Here are my routes:
// ********** Group endpoints *********** //
addRoute(pattern="/user/:userid/groups/:groupid",
handler=“Group”,
action={
GET = “getGroup”,
PUT = “updateGroup”,
DELETE = “removeGroup”
});
addRoute(pattern="/user/:userid/groups/",
handler=“Group”,
action={
POST = “createGroup”,
GET = “getUserGroups”
});
These successfully map to my methods in my handler.
Handler code: (just including the relevant code not all code in the handler)
this.allowedMethods = {getGroup=‘GET’,getUserGroups=‘GET’,createGroup=‘POST’,updateGroup=‘PUT’,removeGroup=‘DELETE’};
function updateGroup(event){
var rc = event.getCollection();
rc.results.setData(‘update group - #rc.groupname#’);
/*
event.paramValue(‘contacts’,’’);
validationResult = validateThis.validate(theObject=rc,objectType=“GroupCreate”);
if(!validationResult.hasErrors() ){
rc.group = entityLoadByPK(‘Group’,rc.groupid);
rc.group.populate(rc);
rc.group.save();
//TODO: app contacts to GroupUser, validate user contacts exists prior to saving
if(listLen(rc.contacts)){
}
rc.results.setData(groupService.getGroup(rc.group.getGroupID()));
}else{
//return validation errors
rc.results.setStatus(403);
rc.results.setData(ArrayToList(validationResult.getFailureMessages(),’,’));
}
*/
}
setData() is an implicit setter in RESTResultsModel. In my PUT request I have several parameters - groupname is one of them. When I run the PUT I get an exception saying that groupname is not defined in rc. When I run a POST with the same parameters (on a method which allows POST) I am able to reference by rc.groupname. Are you saying that for PUT’s, the data needs to be accessed by getHTTPRequestData().content instead as rc.{variablename}?
Thanks very much.
Best,
Nolan