Eric,
Scott and I were looking over this together, and a solution would
be to use the dataMap feature in amplify.request. (See for more info.)
Your request definition would look like this: amplify.request.define(
"update_group",
"ajax",
{
url: "/portal/v1/group/{groupId}",
dataType: "json",
contentType: "application/json",
type: "POST",
decoder: function (data, status, xhr, success, error)
{
if (status === "success") {
success(data, status, xhr);
}
else {
error(data, status, xhr);
}
}
dataMap: function(data) {
if(typeof data === 'object') {
return JSON.stringify(data);
}
return data;
}
}
Since the definition has a contentType of "application/json", the
assumption can be made that if the data member is still an object, we
can stringify it to get a valid JSON body for the request. The
dataMap function will fire *after* the url substitution has occurred,
so it will not interfere with that process.
Thanks!
Jim