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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:14:57+00:00 2026-06-19T03:14:57+00:00

I have a very simple Web API 4 controller over some legacy database code.

  • 0

I have a very simple Web API 4 controller over some legacy database code. The entity like like this:

public class Employee
{
    public string EmploymentStatus { get; set; }
    public string CompanyCode { get; set; }
    public string Division { get; set; }
    public string OrgLevel1Code { get; set; }
    public string OrgLevel2Code { get; set; }
    public string OrgLevel3 { get; set; }
    public string StoreName { get; set; }
    public string EmployeeNumber { get; set; }
    public string EmployeeFirstName { get; set; }
    public string EmployeeMiddleInitial { get; set; }
    public string EmployeeLastName { get; set; }
    public string EmailAddress { get; set; }
    public string JobCode { get; set; }
    public string DateInJob { get; set; }
    public string OriginalHire { get; set; }
}

The method looks like this:

    public HttpResponseMessage PostEmployee(Employee item)
    {
        DataHelpers.AddUser(item.CompanyCode, item.Division, item.OrgLevel1Code, item.OrgLevel2Code, item.OrgLevel3, item.EmployeeFirstName, item.EmployeeMiddleInitial, item.EmployeeLastName, item.EmailAddress, item.JobCode, item.OriginalHire);
        var response = Request.CreateResponse<Employee>(HttpStatusCode.Created, item);
        string uri = Url.Link("DefaultApi", new { id = item.EmployeeNumber });
        response.Headers.Location = new Uri(uri);
        return response;
    }

When I POST through Fiddler like this:

POST /api/identity HTTP/1.1
User-Agent: Fiddler
Host: localhost:1421
Content-Length: 382
contentType: "application/json; charset=utf-8"
dataType: 'json'

{
"employmentStatus":"zzz",
"companyCode":"Titlemax",
"division":"bbb",
"orgLevel1Code":"ccc",
"orgLevel2Code":"ddd",
"orgLevel3":"eee",
"storeName":"fff",
"employeeNumber":"12343",
"employeeFirstName":"Bill",
"employeeMiddleInitial":"A",
"employeeLastName":"sempf",
"emailAddress":"bill@sempf.net",
"jobCode":"GM",
"dateInJob":"8/7/2005",
"originalHire":"8/7/2005"
}

I get an exception from .NET and the item parameter is null.

{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException"}

What am I missing? I’m new to the Web API. Thanks 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-06-19T03:14:58+00:00Added an answer on June 19, 2026 at 3:14 am

    I think it is the request format in Fiddler. Try removing the quotes from the Content-Type header

    From the Composer tab:

    POST http://localhost:1421/api/identity HTTP/1.1
    

    Request Headers:

    User-Agent: Fiddler
    Host: localhost:1421
    Content-Type: application/json; charset=utf-8
    

    Request Body:

    {
       "employmentStatus":"zzz",
       "companyCode":"Titlemax",
       "division":"bbb",
       "orgLevel1Code":"ccc",
       "orgLevel2Code":"ddd",
       "orgLevel3":"eee",
       "storeName":"fff",
       "employeeNumber":"12343",
       "employeeFirstName":"Bill",
       "employeeMiddleInitial":"A",
       "employeeLastName":"sempf",
       "emailAddress":"bill@sempf.net",
       "jobCode":"GM",
       "dateInJob":"8/7/2005",
       "originalHire":"8/7/2005"
    }
    

    Response:

    HTTP/1.1 201 Created
    Cache-Control: no-cache
    Pragma: no-cache
    Content-Type: application/json; charset=utf-8
    Expires: -1
    Location: http://localhost:1421/api/identity/12343
    Server: Microsoft-IIS/8.0
    X-AspNet-Version: 4.0.30319
    X-SourceFiles: =?UTF-8?B?YzpcdXNlcnNcY2FsdmlfMDAwXGRvY3VtZW50c1x2aXN1YWwgc3R1ZGlvIDIwMTJcUHJvamVjdHNcTXZjQXBwbGljYXRpb24yXE12Y0FwcGxpY2F0aW9uMlxhcGlcaWRlbnRpdHk=?=
    X-Powered-By: ASP.NET
    Date: Thu, 21 Feb 2013 03:53:04 GMT
    Content-Length: 351
    
    {"EmploymentStatus":"zzz","CompanyCode":"Titlemax","Division":"bbb","OrgLevel1Code":"ccc","OrgLevel2Code":"ddd","OrgLevel3":"eee","StoreName":"fff","EmployeeNumber":"12343","EmployeeFirstName":"Bill","EmployeeMiddleInitial":"A","EmployeeLastName":"sempf","EmailAddress":"bill@sempf.net","JobCode":"GM","DateInJob":"8/7/2005","OriginalHire":"8/7/2005"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple Web API project. I have a data model, generated
I have deployed a very simple WEB Api project to Windows Azure and am
I have a very simple long polling ajax call like this: (function poll(){ $.ajax({
I have a very simple web service that returns a string (hardcoded at that).
We have a very simple ASP.NET web application comprising mostly static content and a
What I have created a very simple asp.net web service using .NET framework 3.5,
I have a very simple Mac Cocoa app that just has a Web View
Hope you are fine. I have to make a Web Project (very simple) I
I have very simple piece of code. The goal is when i input four-digit
I think I have a very simple problem. I'm currently working on an 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.