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 610945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:43:49+00:00 2026-05-13T17:43:49+00:00

I’m trying to consume twitter’s REST api mentioned at this link using WCF REST

  • 0

I’m trying to consume twitter’s REST api mentioned at this link using WCF REST starter kit mentioned at this link.

I’m using the same objects in DataContract as mentioned in the article – statusList and status.

[assembly: ContractNamespace("", ClrNamespace = "TwitterShell")]
[CollectionDataContract(Name = "statuses", ItemName = "status")]
public class statusList : List<status> { }
public class user
{
    public string id;
    public string name;
    public string screen_name;
}
public class status
{
    public string id;
    public string text;
    public user user;
}

I’m reading the XML contents using ReadAsDataContract() method.

HttpClient http = new HttpClient("http://twitter.com/statuses/");
http.TransportSettings.Credentials =
    new NetworkCredential("{username}", "{password}");
HttpResponseMessage resp = http.Get("friends_timeline.xml");
resp.EnsureStatusIsSuccessful();
statusList sList = resp.Content.ReadAsDataContract<statusList>();

And I get the following exception. I have not defined the following namespace at all.

Error in line 1 position 24. Expecting element ‘statuses’ from namespace ‘http://schemas.datacontract.org/2004/07/sitename‘.. Encountered ‘Element’ with name ‘statuses’, namespace ”.

Please help. Thanks.

  • 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-05-13T17:43:50+00:00Added an answer on May 13, 2026 at 5:43 pm

    Just don’t do it. You are in for a world of pain if you try using Datacontracts and operation contracts to access non-wcf services.

    Ok, so I guess that was a bit unfair leaving you high and dry without an alternative, so try this:

    var response = client.Get("http://twitter.com/statuses/friends_timeline.xml");
    
    var statuses = response.Content.ReadAsXElement();
    
    var statusQuery = from st in statuses.Elements("status")
                      select new status {
                                    id = st.Element("id").Value,
                                    text = st.Element("text").Value,
                                    user = (from us in st.Elements("user")
                                            select new user {
                                                 id = us.Element("id").Value,
                                                 name = us.Element("name").Value,
                                                 screen_name = us.Element("screen_name").Value
                                                             }).FirstOrDefault()
                                          };
    var statuses = statusQuery.ToList();
    

    Using Linq to XML to create objects from the XML document allows you to avoid the magic of serializers and completely control the names and datatypes of your client side objects. It would be really easy to wrap this as a new HttpContent extension method so that you could simply do:

    var statuses = response.Content.ReadAsTwitterStatuses();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 373k
  • Answers 374k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have a look at this answer, esp. the android:cacheColorHint part. May 14, 2026 at 7:47 pm
  • Editorial Team
    Editorial Team added an answer if you want only background process. How to - Set… May 14, 2026 at 7:47 pm
  • Editorial Team
    Editorial Team added an answer In this case JavaScript is the simple hack. Take a… May 14, 2026 at 7:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.