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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:38:08+00:00 2026-06-13T11:38:08+00:00

I am calling a RESTful web service (hosted in Azure) from my Windows Store

  • 0

I am calling a RESTful web service (hosted in Azure) from my Windows Store App (Windows Metro App). This is the Service definition:

[OperationContract]
[WebInvoke(UriTemplate="/Test/PostData", 
    RequestFormat= WebMessageFormat.Json, 
    ResponseFormat= WebMessageFormat.Json, Method="POST", 
    BodyStyle=WebMessageBodyStyle.WrappedRequest)]
string PostDummyData(string dummy_id, string dummy_content, int dummy_int);

From the Windows Store Apps, when calling, I am getting Request Error after posting (it did not even hit the breakpoint I placed in PostDummyData. I have tried the following methods:

Using a StringContent object

using (var client = new HttpClient())
{
  JsonObject postItem = new JsonObject();
  postItem.Add("dummy_id", JsonValue.CreateStringValue("Dummy ID 123"));
  postItem.Add("dummy_content", JsonValue.CreateStringValue("~~~Some dummy content~~~"));
  postItem.Add("dummy_int", JsonValue.CreateNumberValue(1444));

  StringContent content = new StringContent(postItem.Stringify());
  using (var resp = await client.PostAsync(ConnectUrl.Text, content))
    {
        // ...
    }
}

Using a HttpRequestMessage

using (var client = new HttpClient())
{
  JsonObject postItem = new JsonObject();
  postItem.Add("dummy_id", JsonValue.CreateStringValue("Dummy ID 123"));
  postItem.Add("dummy_content", JsonValue.CreateStringValue("~~~Some dummy content~~~"));
  postItem.Add("dummy_int", JsonValue.CreateNumberValue(1444));

  StringContent content = new StringContent(postItem.Stringify());
  HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, ConnectUrl.Text);
  msg.Content = content;
  msg.Headers.TransferEncodingChunked = true;

  using (var resp = await client.SendAsync(msg))
    {
        // ...
    }
}

I’d figured that it may be the content-type header that is having problem (last checked it was set to plain text, but I can’t find a way to change it).

The HTTP GET methods are all working fine though. Would appreciate if somebody can point me to a correct direction. 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-06-13T11:38:09+00:00Added an answer on June 13, 2026 at 11:38 am

    You should set the content-type in the StringContent object:

    StringContent content = new StringContent(postItem.Stringify());
    content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/json");
    

    or directly in the constructor:

    StringContent content = new StringContent(postItem.Stringify(),
        Encoding.UTF8, "text/json");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please bear with me for this novice question. I am calling a RESTful web
I'm trying to call a RESTful web service from an Android application using the
I am having a heck of a time calling a RESTful service from within
I have a RESTful API serving JSON. I'm calling it like this: - (void)viewDidLoad
While calling from my Web Application, WCF response i am getting is : <s:Envelope
I have a RESTful WCF web service called "Palladium" as a project in my
I am writing a RESTful web service where in I want to return a
I am calling a restful service that returns JSON using the Apache HttpClient. The
I'm building a web service with a RESTful interface (lets call it MY_API ).
I'm building a web service with a RESTful interface (lets call it MY_API ).

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.