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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:31:07+00:00 2026-05-26T16:31:07+00:00

I found you are the only one who answers for service stack, I don’t

  • 0

I found you are the only one who answers for service stack, I don’t have emails and what ever you provided for last questions to me, seems fine.

I have seen your profile and as you are the main founder of mythZ, i seems to ask you my question again.

For one of my question, POST data in JSON format to Service stack, i appreciate your answer.
your answer is right, however in my case i am having following case.Let me describe in more detail.

I have seen “Hello World” example of service stack. I got link for
https://github.com/ServiceStack/ServiceStack.Extras/blob/master/doc/UsageExamples/UsingRestAndJson.cs

In my case,
I am having console application which calls service stack (which inserts data in DB)
Now, in that console application, i have made one class (class1) which is there in service stack with the same properties.

I assign values to properties of that class in my console application and POST the whole object to service stack. Syntex is like below

 JsonServiceClient client = new JsonServiceClient(myURL);
       MYclass cls= MakeObjectForServiceStackToInsertData();
        var res = client.Post<MYClass>("/postrequest", cls); 

I have use POST as above. which seems okay.
at the service stack end in OnPOST event, i get this data and insert in DB.
It is working fine for me.

Now my client, wants that we need to pass data in any format. JSON/XML.
I know it is possible as you provide me a “Hello world” example link, it is mention over there.

But all i found is, they have used ajax/Jquery to post data to service.
In my case this is console application, so i am not able to use ajax/Jquery.
I am wondering that, is it possible to pass data in JSON format and do operation in my case.

Thank you very much in advance.

  • 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-26T16:31:07+00:00Added an answer on May 26, 2026 at 4:31 pm

    So if you want to post any untyped and free-text JSON or XML to ServiceStack then you wont be able to ServiceStack’s generic typed C# clients (i.e. its JsonServiceClient, XmlServiceClient, etc). Instead you just need to use any basic Http Client like the HttpWebRequest that comes with .NET.

    As I’ve mentioned earlier sending free-text json or xml is not the normal way to call ServiceStack web services (i.e. it’s recommended to use typed DTOs and one of the generic service client), but since you’ve asked here are stand-alone, dependency-free examples of how to call ServiceStack’s Hello World example web service:

    Sending free-text JSON

    const string RemoteUrl = "http://www.servicestack.net/ServiceStack.Hello/servicestack/hello";
    
    var httpReq = (HttpWebRequest)WebRequest.Create(RemoteUrl);
    httpReq.Method = "POST";
    httpReq.ContentType = httpReq.Accept = "application/json";
    
    using (var stream = httpReq.GetRequestStream())
    using (var sw = new StreamWriter(stream))
    {
        sw.Write("{\"Name\":\"World!\"}");
    }
    
    using (var response = httpReq.GetResponse())
    using (var stream = response.GetResponseStream())
    using (var reader = new StreamReader(stream))
    {
        Assert.That(reader.ReadToEnd(), Is.EqualTo("{\"Result\":\"Hello, World!\"}"));
    }
    

    Sending free-text XML

    var httpReq = (HttpWebRequest)WebRequest.Create(RemoteUrl);
    httpReq.Method = "POST";
    httpReq.ContentType = httpReq.Accept = "application/xml";
    
    using (var stream = httpReq.GetRequestStream())
    using (var sw = new StreamWriter(stream))
    {
        sw.Write("<Hello xmlns=\"http://schemas.servicestack.net/types\"><Name>World!</Name></Hello>");
    }
    
    using (var response = httpReq.GetResponse())
    using (var stream = response.GetResponseStream())
    using (var reader = new StreamReader(stream))
    {
        Assert.That(reader.ReadToEnd(), Is.EqualTo("<HelloResponse xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.servicestack.net/types\"><Result>Hello, World!</Result></HelloResponse>"));
    }
    

    I have added the above examples into this Runnable Unit Test.

    I recommend getting familiar with a HTTP traffic analyzer tool so you can easily see the HTTP traffic that is sent and received to and from your web service. From then on, being able to workout how to call your service becomes trivial. Some great HTTP traffic analyzers include:

    • Fiddler
    • Network inspectors in Browser (e.g. Chrome, Safari, Firefox and IE have great tools)
    • WireShark
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found only one attempt to create such compiler - http://sourceforge.net/projects/xsltc/ . But this
When I looked at: http://replicaisland.googlecode.com/svn/trunk/res/drawable/ and found it only had one set of images,
Can you somehow lock an iPad to Safari and only one webpage? I've found
After I made some researches, I found out there is only one way to
I have found only two methods (SaveFile, LoadFile) which save in a file. How
The SSE shift instructions I have found can only shift by the same amount
I have looked all around and only found solutions for python 2.6 and earlier,
I have a asp.NET web service (not WCF but the classic .asmx one with
I have a screen with several UserControls, but only one of them remains active.
I have a php/mysql application. There are users who have folders. Folders can only

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.