I have this REST api I make REST api calls to the Webservice for Instance
http://localhost:56295/api/EmployeeDB
It returns this Results on PostMan
[
{
"Fullname": "James Hall",
"Telephone": "08020772008",
"gender": "Male",
"email": "[email protected]",
"date_ofbirth": "1988-05-19T00:00:00",
"nationalID": "7862367AS",
"accountnumber": "2093993827",
"salary": 980000.00
},
{
"Fullname": "Temi Lawson",
"Telephone": "08038220163",
"gender": "Female",
"email": "[email protected]",
"date_ofbirth": "1987-12-22T00:00:00",
"nationalID": "7627862SS",
"accountnumber": "2099302931",
"salary": 450000.00
},
{
"Fullname": "Qalid R. Osman - Hussein",
"Telephone": "08022712782",
"gender": "Male",
"email": "[email protected]",
"date_ofbirth": "1989-06-02T00:00:00",
"nationalID": "873909ED",
"accountnumber": "2002198291",
"salary": 2328500.00
},
{
"Fullname": "John Snow",
"Telephone": "08147720192",
"gender": "Male",
"email": "[email protected]",
"date_ofbirth": "1985-06-22T00:00:00",
"nationalID": "JS834788US",
"accountnumber": "0034773291",
"salary": 800000.00
},
{
"Fullname": "Tina Martins",
"Telephone": "08128823781",
"gender": "Female",
"email": "[email protected]",
"date_ofbirth": "1985-07-25T00:00:00",
"nationalID": "J834712US",
"accountnumber": "0331928271",
"salary": 750500.00
},
{
"Fullname": "Fred Hammond",
"Telephone": "08026626128",
"gender": "Male",
"email": "[email protected]",
"date_ofbirth": "1982-11-25T00:00:00",
"nationalID": "KL328327D",
"accountnumber": "0440123920",
"salary": 2750500.00
},
{
"Fullname": "Jack Holland",
"Telephone": "08026626128",
"gender": "Male",
"email": "[email protected]",
"date_ofbirth": "1982-11-25T00:00:00",
"nationalID": "KL328327D",
"accountnumber": "0440123920",
"salary": 855890.00
}
]
Exactly as i wanted, Now I make another REST api Call using a Parameter for instance, http://localhost:56295/api/EmployeeDB?accountnumber=0034773291
And it returns Data for One person
[
{
"Fullname": "John Snow",
"Telephone": "08147720192",
"gender": "Male",
"email": "[email protected]",
"date_ofbirth": "1985-06-22T00:00:00",
"nationalID": "JS834788US",
"accountnumber": "0034773291",
"salary": 800000.00
}
]
But this is for Postman, Now i built something using a Class Library so I can be able to make REST api calls in an Automation application (K2 SmartForms) After which I would convert into a SmartObject
Which has this source code
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace RESTBrowserGET
{
public class BrowseRESTGet
{
public static Object GETRESTInfo(string restUrl, string reqMethod)
{
var request = (HttpWebRequest)WebRequest.Create(restUrl);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
//var obj = JsonConvert.DeserializeObject<JObject[]>(responseString);
var obj = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(responseString, typeof(JObject));
return obj.ToString();
}
}
}
Here comes the main Issue. I want to use the Values retrieved from this Json in an Application, So if for instance, the Class Library makes a REST api call to http://localhost:56295/api/EmployeeDB?accountnumber=0034773291 It should use the Values gotten from this Json
[
{
"Fullname": "John Snow",
"Telephone": "08147720192",
"gender": "Male",
"email": "[email protected]",
"date_ofbirth": "1985-06-22T00:00:00",
"nationalID": "JS834788US",
"accountnumber": "0034773291",
"salary": 800000.00
}
]
In My application to view information from the Database, It does not seem to be returning the Values in a Deserialized Typed Array, What do I seem to be missing? What Am i not doing correctly?