0

Currently I have a resource like so:

 return $resource(usersUrl, {}, {
        //The data model is loaded via a GET request to the app
        query: {method: 'GET', params: {}, isArray: false},
        putupdate: {method: 'PUT', params:{}}
    });

Now I would like to put some JSON that looks like:

{"providerid":"userpass","firstname":"t","lastname":"b","fullname":"t b","email":"emailaddress,"avatarurl":"http:/.....","passwordset":true}

Anyway as you can see it doesn't have a top level name, if I pass this information in as a parameter to the resource a name is appended to the json like:

myparam:{"providerid":"userpass","firstname":"t","lastname":"b","fullname":"t b","email":"emailaddress,"avatarurl":"http:/.....","passwordset":true}

Is there a away of preventing this from happening as the server side doesn't like it?

Thanks

Tom

1
  • I think that we will need more code to help... Try to reproduce this case at a fiddle :D Commented May 15, 2013 at 0:21

1 Answer 1

1

From your question it sounds like you are trying to use $resource to post some arbitrary json data. If this data is not a Resource() you should simply use $http.

$http.put(theUrl, theJsonData);

If it is actually a Resource() you can just call the method you declared when building your resource.

myResource.putupdate();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Mark, the data is user information in the webapp and so is picked up from a rest endpoint and processed, sounds resourceful enough to me, although i've only been using AngularJS for 24 hours, so I am probably wrong :) I'm a bit confused though, how does calling the method post the json back in the body, i've played with that and failed to pass anything back to the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.