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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:50:35+00:00 2026-06-12T12:50:35+00:00

I have created a webservice in C# which looks like this: [WebMethod] [ScriptMethod(ResponseFormat =

  • 0

I have created a webservice in C# which looks like this:

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string UpdateHeatCallJSON(string json)
    {
        HeatItem item = JsonConvert.DeserializeObject<HeatItem>(json);
        UpdateHeatCall(item);
        HeatItemResponse response = new HeatItemResponse();
        //... more code
        return JsonConvert.SerializeObject(response);
    }

I basically have an object HeatItem, which I want to pass in as an argument.

I currently consume the web service (for testing) in a C# console application and having challenges finding the correct format. This is my call:

   static void UpdateHeatItemJSON()
    {
        // corrected to WebRequest from HttpWebRequest
        WebRequest request = WebRequest.Create(requestServer + "/UpdateHeatCallJSON");

        request.Method = "POST";
        request.ContentType = "application/json; charset=utf-8";
        string postData = "";
        postData = @"{'json':'{""BusinessPartner"":""00000000-0000-0000-0000-000000000000"",""CaseNumber"":4,""CaseDescription"":""first case"",""CaseType"":"""",""CaseSeverity"":"""",""DueDate"":""0001-01-01T00:00:00"",""AssignmentNumber"":5,""AssignmentDescription"":"""",""AssignmentCreation"":""0001-01-01T00:00:00"",""AssignmentTime"":""0001-01-01T00:00:00"",""ChangeDate"":""0001-01-01T00:00:00"",""ChangeTime"":""0001-01-01T00:00:00"",""Group"":"""",""SubGroup"":"""",""Module"":"""",""AssignmentStatus"":"""",""KPIChallenge"":false,""KPI1Status"":"""",""KPI1User"":"""",""KPI1Date"":""0001-01-01T00:00:00"",""KPI1Time"":""0001-01-01T00:00:00"",""KPI2Status"":"""",""KPI2User"":"""",""KPI2Date"":""0001-01-01T00:00:00"",""KPI2Time"":""0001-01-01T00:00:00"",""SessionID"":null}'}";

        System.Diagnostics.Debug.Print(postData);

        //get a reference to the request-stream, and write the postData to it
        using (Stream s = request.GetRequestStream())
        {
            using (StreamWriter sw = new StreamWriter(s))
                sw.Write(postData);
        }

        //get response-stream, and use a streamReader to read the content
        using (Stream s = request.GetResponse().GetResponseStream())
        {
            using (StreamReader sr = new StreamReader(s))
            {
                string jsonData = sr.ReadToEnd();
                JObject jObject = JObject.Parse(jsonData);
                JToken jHeatItem = jObject["HeatItem"];
            }
        }
    }

Looking at postData above, formatting the json string as above works, however when I validate the string at http://jsonlint.com/ the validation fails. When I pass in a validated json string like this:

{
“json”: {
“BusinessPartner”: “00000000-0000-0000-0000-000000000000”,
“CaseNumber”: 4,
“CaseDescription”: “first case”,
“CaseType”: “”,
“CaseSeverity”: “”,
“DueDate”: “0001-01-01T00:00:00”,
“AssignmentNumber”: 5,
“AssignmentDescription”: “”,
“AssignmentCreation”: “0001-01-01T00:00:00”,
“AssignmentTime”: “0001-01-01T00:00:00”,
“ChangeDate”: “0001-01-01T00:00:00”,
“ChangeTime”: “0001-01-01T00:00:00”,
“Group”: “”,
“SubGroup”: “”,
“Module”: “”,
“AssignmentStatus”: “”,
“KPIChallenge”: false,
“KPI1Status”: “”,
“KPI1User”: “”,
“KPI1Date”: “0001-01-01T00:00:00”,
“KPI1Time”: “0001-01-01T00:00:00”,
“KPI2Status”: “”,
“KPI2User”: “”,
“KPI2Date”: “0001-01-01T00:00:00”,
“KPI2Time”: “0001-01-01T00:00:00”,
“SessionID”: null
}
}

the webservice returns a 500 Internal Server Error, which I believe is because it does not like the argument passed in. I am relatively new to this and I am wondering if anyone can help me understand this a bit better.

Also looking at the response (for the working example), the return json contains three backslaches \\ I believe to escape the quotation marks. This makes this call

                JObject jObject = JObject.Parse(jsonData);
                JToken jHeatItem = jObject["HeatItem"];

to fail. Any ideas why?

Thanks
Thomas

  • 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-12T12:50:37+00:00Added an answer on June 12, 2026 at 12:50 pm

    Feeling like an idiot wasting a lot of time on this, now as everyhing is so easy. Let asp.net take care of it. Followed the steps in this post and all is working perfectly

    http://encosia.com/asp-net-web-services-mistake-manual-json-serialization/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: This might look like duplicate but its not. I have created a .net(WCF)
I have created a web service which is saving some data into to db.
I have created a web service which takes a username and password as parameters
I have created a web service which returns some data and am trying to
I have created a RESTful PHP web service using Lithium which contains comments, each
I have a web service in which I created an enum.. i have a
I have a winforms, and it connecting wit webservice. Webservice has method which create
I have created a helper to parse time froma webservice and output inanother format
I have created one application in flex that is accessing the Java webservice using
I have created a function in PHP that calls a webservice and parses through

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.