I am new to REST API JSON but have been able to consume a few API with asp.net. Here is the problem I am currently facing.
I have been able to send JSON data to an API using this method.
public void PostData(){ string sName = sysName.Text; string sDescrip = sysDescrip.Text; var httpclient = new HttpClient(); httpclient.BaseAddress = new Uri("http://33.248.292.99:8094/bizzdesk/sysconfig/api/"); var sys = new Bizsys(){name= sName, description= sDescrip}; httpclient.PostAsJsonAsync("system", sys);}
it work just fine.
Now I modify the code in order to accommodate more values thus:
var httpclient = new HttpClient();// ArrayList paramList = new ArrayList();httpclient.BaseAddress = new Uri("http://179.683.197.115:9091/tua-slte/api/organisations/");var org = new Organisation() { id=1, name = "inno", abbreviation = "abx", type="school", sort = 7, isShow = true, createdBy=8, createdDate = "10/04/2017", editedBy = 11, editDate="11/04/2017"};var bas = new Basic() { id=1, username = "inno", password = "123", firstName="Innocent", lastName="Ujata", email = "ea@bizz.co", mobile = "123456", photo="10201001", loginIp="127.0.0.1", loginDate="10/04/2017", locked=false, organisation = org, createdDate = "10/04/2017", editedBy = 11, editDate="11/04/2017", admin=true};var org2 = new Organisation2() { id=1, name = "inno", abbreviation = "abx", type="school", sort = 7, isShow = true, createdBy=17, createdDate = "10/04/2017", editedBy = 09, editDate="11/04/2017"};var hq = new HeadQuarter() { zonId=09, organisation = org2, zonCode = "123", zonName = "Abuja", zonAddress = "123456", zonCity = "Abuja", zonPostalCode = "120076", zonEmail = "answers", zonPhoneNumber = "0908765", zonFaxNumber = "1212", zonState = "FCT", createdBy=17, createdDate = "10/04/2017", editedBy = 11, editDate="11/04/2017", version=1};var examp = new RootObject() {basic=bas, headQuarter=hq };var status = httpclient.PostAsJsonAsync("register", examp);return status;
It keep returning this:
Id = 19, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
I hard coded the data to see it work first before making it dynamic.
I have tried using await async method too the result is the same. all the questions and answers I have seen here are not similar.
What does that mean, and what am I getting wrong?