I am trying to use restangular in my project, I have the set up and config all working fine. I need to make a post request where i have the url and a json payload.
var url = xyz.com + "/api/v2/create?type=project";
eg payload
'{
"class":"Project",
"name":"test_project",
"description":"test_project",
"owner":{"class":"User","id":"2"},
"connection":{"class":"Connection","id":"1"},
"defaultNamespace":"default",
"namespaces":["default"]}'
I was unsure of how to make a restangular call, should the post have the payload as params? I tried this below, but did not seem to work.
Restangular.all('create').post({
"class":"Project",
"name":"test_project",
"description":"test_project",
"owner":{"class":"User","id":"2"},
"connection":{"class":"Connection","id":"1"},
"defaultNamespace":"default",
"namespaces":["default"]})
Hey you should do something like:
Restangular.all('create').post(
// First the object
{
class: "Project",
name: "Test-project",
owner: {
class: "User"
}
},
// Then the request params
{type: "Project"}
);
That should do it :)