Calling an External Web API from Controller - No Jquery
The challenge is to call an external API and put it into a model you can use.
The example below has a simple model STAPI_DTO which has two string fields - one of which is a client key which is what I am after
string serviceURL = "https://someurl" + appt.POSID;
var client = new WebClient();
//where STAPI_DTO is my model
STAPI_DTO st = new STAPI_DTO();
STAPI_DTO result = JsonConvert.DeserializeObject(client.DownloadString(serviceURL));
string clientkey = result.APIKEY;
The example below has a simple model STAPI_DTO which has two string fields - one of which is a client key which is what I am after
string serviceURL = "https://someurl" + appt.POSID;
var client = new WebClient();
//where STAPI_DTO is my model
STAPI_DTO st = new STAPI_DTO();
STAPI_DTO result = JsonConvert.DeserializeObject
string clientkey = result.APIKEY;
Comments