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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:08:09+00:00 2026-06-01T22:08:09+00:00

I’m using json.net to perform handle my json deserialization in a IIS hosted restful

  • 0

I’m using json.net to perform handle my json deserialization in a IIS hosted restful service.

First, here are the objects I’m trying to work with.

[DataContract]
public class CreateSamplesRequest
{
    [DataMember] public Guid SessionId { get; set; }
    [DataMember] public SampleTemplateDTO Template { get; set; }
}
[DataContract]
public class SampleTemplateDTO
{
    [DataMember] public int NumberOfSamples { get; set; }
    [DataMember] public int CompanyId { get; set; }
    [DataMember] public int SampleTypeId { get; set; }
    [DataMember] public HmisDTO Hmis { get; set; }
    [DataMember] public List<AttributeValueDTO> AttributeValues { get; set; }   
}
[DataContract]
public class AttributeValueDTO
{
    [DataMember] public int AttributeId { get; set; }
    [DataMember] public string AttributeName { get; set; }
    [DataMember] public string Value { get; set; }
}

[DataContract]
public class HmisDTO
{
    [DataMember] public string Health { get; set; }
    [DataMember] public string Flammability { get; set; }
    [DataMember] public string Reactivity { get; set; }
    [DataMember] public string Equipment { get; set; }
}

The help page asks for json in this format for the CreateSamplesRequest

{
 "SessionId":"1627aea5-8e0a-4371-9022-9b504344e724",
 "Template":{
    "NumberOfSamples":2147483647,
    "CompanyId":2147483647,
    "SampleTypeId":2147483647,
    "Hmis":{
        "Health":"String content",
        "Flammability":"String content",
        "Reactivity":"String content",
        "Equipment":"String content"
    },
    "AttributeValues":[{
        "AttributeId":2147483647,
        "AttributeName":"String content",
        "Value":"String content"
    }]
  }
}

And this is what I’m actually sending:

{
 "SessionId":"17aaec11-be28-4536-b5df-d98fbda91e91",
 "Template":{
    "NumberOfSamples":1,
    "CompanyId":1,
    "SampleTypeId":9,
    "Hmis":{
        "Health":"2",
        "Flammability":"0",
        "Reactivity":"0",
        "Equipment":"E",
    },
   "AttributeValues":[
      {"AttributeId":1,"AttributeName":"Item No.","Value":"MN0002NG"},
      {"AttributeId":2,"AttributeName":"Lot No.","Value":"C4526"}
    ]
 }
}

The problem I’m having is that the AttributeValues property of the SampleTemplateDTO object always ends up being ignored. With the above code, it will be null. If I instanciate it to a empty List<AttributeValueDTO> it will be an empty list. I’ve been banging my head against this for a few hours.

I’ve tried creating a service that just takes a List<AttributeValueDTO> and it works fine. I’ve tried creating a wrapper class for the AttributeValues and it still ends up as null. I’m completely stumped. Any ideas?

  • 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-01T22:08:11+00:00Added an answer on June 1, 2026 at 10:08 pm

    MOTHER OF GOD, I JUST WASTED 5 FREAKING HOURS ON A FREAKING COMMA. The trailing comma in the HMIS section was apparently telling json.net to stop parsing at that point.

    When I submit this json:

    {
     "SessionId":"17aaec11-be28-4536-b5df-d98fbda91e91",
     "Template":{
      "NumberOfSamples":1,
      "CompanyId":1,
      "SampleTypeId":9,
      "Hmis":{
        "Health":"2",
        "Flammability":"0",
        "Reactivity":"0",
        "Equipment":"E"
      },    
      "AttributeValues":[
       {"AttributeId":1,"AttributeName":"Item No.","Value":"MN0002NG"},
       {"AttributeId":2,"AttributeName":"Lot No.","Value":"C4526"}
      ]     
     }
    }
    

    Everything works great.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.