AngularJS forms with Google Cloud Endpoints -


i created api backend:

@apimethod(name = "create", path = "properties", httpmethod = httpmethod.post) public void create(realestatepropertyapi property, user user)         throws exception { } 

with following data model:

public class realestatepropertyapi {      private long id;     private string name;     private addressapi address;      public realestatepropertyapi() {     }      public long getid() {         return id;     }      public void setid(long id) {         this.id = id;     }      public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public addressapi getaddress() {         return address;     }      public void setaddress(addressapi address) {         this.address = address;     }  }  public class addressapi {      private long id;     private string street;     private string city;     private string state;     private string zip;     private string country;      public addressapi() {     }      public long getid() {         return id;     }      public void setid(long id) {         this.id = id;     }      public string getstreet() {         return street;     }      public void setstreet(string street) {         this.street = street;     }      public string getcity() {         return city;     }      public void setcity(string city) {         this.city = city;     }      public string getstate() {         return state;     }      public void setstate(string state) {         this.state = state;     }      public string getzip() {         return zip;     }      public void setzip(string zip) {         this.zip = zip;     }      public string getcountry() {         return country;     }      public void setcountry(string country) {         this.country = country;     }  } 

in api explorer following request works:

post http://localhost:8888/_ah/api/realestate/v1/properties  content-type:  application/json x-javascript-user-agent:  google apis explorer  {  "name": "test",  "address": {   "city": "dc"  } } 

but when using angular js client, realestatepropertyapi instance created fields not populated (all null). request is:

[{"jsonrpc":"2.0","id":"gapirpc","method":"realestate.create","params":{"resource":"{\"name\": \"test\",\"address\": { \"street\": \"white house\"}}"},"apiversion":"v1"}] 

the js call:

    var x = '{"name": "test","address": { "street": "white house"}}';     gapi.client.realestate.create({"resource": x}).execute(function(resp) {         console.log(resp);     }); 

i ran same issue never figured out how solve it. ended not using js library insert method. instead, created call this:

$http({         'url': api_root + '/mobilebackend/v1/cloudentities/insert/private_note',         'datatype': 'json',         'method': 'post',         'data': json.stringify(data),         'headers': {             'content-type': 'application/json; charset=utf-8'         } }).success(function(resp) {         next(resp); }).error(function(error) {         next(error); }); 

i wish had better alternative, i've come far.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -