When we build an application in .net, sometimes we need to get external data from HTTP API web services such as Bing API or Google API service to support our application programs. HTTP API usually return json or xml format to get data value from it services. So we must read json or xml node then parse it to our object entity to get returned value from HTTP API that we access. To get right return value from HTTP API services, we also must set or specify input parameter for HTTP API service that we access. It’s so complicated if we code manually for accessing HTTP API in our application.
RestSharp is open source library for Rest and HTTP API client for .net. It is used to help us when we access Rest and HTTP Api web services. We can download it for free from https://github.com/johnsheehan/RestSharp/archives/master. I will show you how to use this library on Windows Phone 7 Silverlight Application to get Google News API . Let’s start..
Prepare your windows phone 7 project application. We put some user control to the windows phone page like text box to get news keyword, button to handle event for call method, and listbox to display data result.
Don't forget add RestSharp library references (Newtonsoft.Json.Silverlight and RestSharp.WindowsPhone) to our project.

Add New Entity Class name it “SearchResult.cs” to represent news data object getting from google news api.
1 public class SearchResult
2 {
3 public string Title { get; set; }
4 public string Content { get; set; }
5 public string Url { get; set; }
6 public string TitleNoFormatting { get; set; }
7 public string Publisher { get; set; }
8 public string UnescapedUrl { get; set; }
9 public DateTime PublishedDate { get; set; }
10 }
Add LoadNews method to get http api request from rest client.
1 public void LoadNews(string keyword)
2 {
3 var client = new RestClient("https://ajax.googleapis.com/ajax/services/search/news");
4 var request = new RestRequest(Method.GET);
5 request.AddParameter("v", "1.0");
6 request.AddParameter("q", keyword);
7 request.AddParameter("hl", "id");
8 request.AddParameter("rsz", 5);
9
10 client.ExecuteAsync<SearchResult>(request, (response) =>
11 {
12 try
13 {
14 var resource = response.Data;
15 listBox1.Items.Clear();
16
17 JObject googleSearch = JObject.Parse(response.Content);
18 JEnumerable<JToken> results = googleSearch["responseData"]["results"].Children();
19 IList<SearchResult> searchResults = new List<SearchResult>();
20 foreach (JToken result in results)
21 {
22 SearchResult searchResult = JsonConvert.DeserializeObject<SearchResult>(result.ToString());
23 searchResults.Add(searchResult);
24 }
25
26 foreach (SearchResult t in searchResults)
27 {
28 listBox1.Items.Add(HttpUtility.HtmlDecode(t.TitleNoFormatting));
29 }
30
31
32 if (searchResults.Count == 0)
33 {
34 MessageBox.Show("Sorry, empty result.");
35 }
36 }
37 catch (Exception e)
38 {
39 MessageBox.Show(e.Message);
40 }
41 });
42
43 }
Then add event button click to get data from google API based on keyword from input user.
1 private void button1_Click(object sender, RoutedEventArgs e)
2 {
3 LoadNews(textBox1.Text);
4 }
Oke lets try…

You can download the source code
here.. :)