Last active
May 12, 2018 06:21
-
-
Save gsedubun/c3bf991a444019b50d3e483a38ea99f8 to your computer and use it in GitHub Desktop.
restshart consume rest json api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void SerializeRestSharp(string resourceUrl) | |
{ | |
var client = new RestClient("https://www.idx.co.id"); | |
client.AddDefaultHeader(HttpRequestHeader.ContentType.ToString(), "application/json"); | |
var req = new RestRequest(resourceUrl, Method.GET); | |
var res = client.ExecuteAsGet(req, Method.GET.ToString());//, res => | |
if (res.IsSuccessful) | |
{ | |
var listingdata = JsonConvert.DeserializeObject<ListingData>((string)JToken.Parse(res.Content)); | |
System.Console.WriteLine("{0}-{1}", listingdata.Activities[0].KodeEmiten, listingdata.Activities[0].NamaEmiten); | |
} | |
else | |
System.Console.WriteLine(res.StatusCode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment