Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:33:26+00:00 2026-06-12T22:33:26+00:00

I am using RestSharp to retrieve some data from Cambridge Dictionaries API for a

  • 0

I am using RestSharp to retrieve some data from Cambridge Dictionaries API for a simple Windows Phone 7 Application. When I perform my search query I get the results in JSON because I check the response.Content and the results are actually returned however when I try to deserialize the result and bind it to a list box element it wont work.
Here is the code:

Request Handler Class

namespace RestAPI
{
/// <summary>
/// This class is responsible for communicating with a RESTful web service.
/// </summary>
public class RequestHandler
{
    //this property stores the API key
    readonly string Accesskey = "";

    //this property stores the base URL
    readonly string BaseUrl =  "https://dictionary.cambridge.org/api/v1/dictionaries/british/search";
    //readonly string BaseUrl = "https://dictionary.cambridge.org/api/v1/dictionaries";

    //Instance of the RestClient
    private RestClient client;



    //Constructor that will set the apikey 
    public RequestHandler(string Access="Doh52CF9dR8oGOlJaTaJFqa05PysEKIbEvd9VNQ7CqB81MyTUCggGNQO7PDyrsyY")
    {
        this.Accesskey = Access.Trim();
        client = new RestClient(this.BaseUrl);
    }

    //Execute function

    public List<SearchResult> Execute(string word)
    {
        List<SearchResult> data = new List<SearchResult>();
        RestRequest request = new RestRequest();
        request.RequestFormat = DataFormat.Json;
        request.AddHeader("accessKey",Accesskey);
        request.AddParameter("pageIndex","1");
        request.AddParameter("pageSize","5");
        request.AddParameter("q",word.Trim());


        client.ExecuteAsync<List<SearchResult>>(request,(response)=>{


            try
            {
            var resource = response.Data;

            if(response.ResponseStatus == ResponseStatus.Completed)
                MessageBox.Show(resource.Count.ToString());


            //MessageBox.Show(resource.ToString());

            foreach(SearchResult s in resource)
            {
                data.Add(s);
               }
            }
        catch(Exception e)
        {
            MessageBox.Show(e.Message);
        }


    });

        return data;    
      }
}
}

code behind file of main page.

namespace RestAPI
{
public partial class MainPage : PhoneApplicationPage
{
    public RequestHandler handler = new RequestHandler();
    public List<SearchResult> info = new List<SearchResult>();

    // Constructor
    public MainPage()
    {
        InitializeComponent();
    }

    private void search_Click(object sender, RoutedEventArgs e)
    {
        info = handler.Execute(searchBox.Text);
        listBox1.Items.Add("Testing");
        foreach (SearchResult s in info)
        {
            listBox1.Items.Add(s.entryLabel);

        }
    }
}
 }

Model class that the data is being deserialized to.

namespace RestAPI
{
public class SearchResult
{

    public string entryLabel{get;set;}
    public string entryUrl{get;set;}
    public string entryId { get; set; }

}

}

Sample JSON data that is being returned.

{
"resultNumber": 49,
"results": [
    {
        "entryLabel": "dog noun  ANIMAL ",
        "entryUrl": "http://dictionary.cambridge.org/dictionary/british/dog_1",
        "entryId": "dog_1"
    },
    {
        "entryLabel": "dog noun  PERSON ",
        "entryUrl": "http://dictionary.cambridge.org/dictionary/british/dog_2",
        "entryId": "dog_2"
    },
    {
        "entryLabel": "dog verb  FOLLOW ",
        "entryUrl": "http://dictionary.cambridge.org/dictionary/british/dog_3",
        "entryId": "dog_3"
    }
],
"dictionaryCode": "british",
"currentPageIndex": 1,
"pageNumber": 17
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:33:27+00:00Added an answer on June 12, 2026 at 10:33 pm

    Something like this should do the trick:

    public class SearchResultResponse
    {
        public int ResultsNumber { get; set; }
        public IEnumerable<SearchResult> Results { get; set; }
    }
    
    public class SearchResult
    {
    
        public string entryLabel { get; set; }
        public string entryUrl { get; set; }
        public string entryId { get; set; }
    }
    
    SearchResultResponse obj = JsonConvert.DeserializeObject<SearchResultResponse>(json);
    

    In your case you might have to call the client.ExecuteAsync like this:

    client.ExecuteAsync<SearchResultResponse>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble regarding a rest request sent from my Windows Phone app
New to OAuth and RestSharp. I'm building a Windows Phone app, using RestSharp to
Im trying to read some json data using RestSharp. But im having some problems
I have a phone app that trys to GET data from my web api
I am trying to create a simple iPhone application using HTML/JavaScript/CSS with the help
Using Android TelephonyManager an application can obtain the state of data activity over the
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
I'm trying to retrieve a Twitter OAuth request token using RestSharp, but no matter
I'm using RestSharp in a Mono project to upload some files and I have
Recently I was using RestSharp to consume my Restful Resouce. and expected exchanging data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.