I have a pretty simple WebAPI controller:
[HttpGet] public IQueryable<User> GetUsers() { return _users.AsQueryable(); } [HttpPost] public User AddUser(User toAdd) { _userRepository.AddUser(toAdd); }
and the User object is also simple:
public class User { public String name { get; set; } public String email { get; set; } }
(obviously, some of the boring parts are left out!)
Posting to the service works fine through a C # call, a jQuery call, etc.
With javascript / jquery, I would do something like:
var user = { "Name" : "Persons Name", "Email" : " Email@Email.com " } var processed = JSON.stringify(user); $.ajax({ url: url, data: processed, success: .... ... });
I am trying to get it on POST with Objective-C. GET works fine, so I know that it can connect, etc.
I tried all kinds of things to try to get it to publish the object via JSON, but I had no luck. Can someone point me in the right direction?
Thanks!
source share