0

I have created a WebAPI POST Method for Registration. When I test the service using POSTMAN, the model object is always NULL. I I googled the issue a lot, but nothing seems to work for me.

My code is below:

 public HttpResponseMessage PostStudent(EmployeeModel emp)
    {
        if (ModelState.IsValid)
        {
            using (HRMSEntities reg = new HRMSEntities())
            {
                APIRegistration entities = new APIRegistration();
                entities.Emp_No = emp.EmpNumber;
                entities.MobileNo = emp.MobileNumber;
                entities.IMEINo = emp.IMEINumber;
                entities.GPS_LAT = emp.GPSLatitude;
                entities.GPS_LOG = emp.GPSLog;
                entities.GPS_LOCATION = emp.GPSLocation;

                reg.APIRegistrations.Add(entities);
                reg.SaveChanges();

                var response = Request.CreateResponse<EmployeeModel>(HttpStatusCode.OK, emp);
                return response;
            }
        }
        else
        {
            return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Emplyee not found"); 
        }


    } 

And this is my POST Request:

POST/api/Registration
Cache-Control →no-cache
Content-Length →26
Content-Type →application/json; charset=utf-8
Date →Wed, 25 Apr 2018 05:41:48 GMT
Expires →-1
Pragma →no-cache
Server →Microsoft-IIS/10.0
X-AspNet-Version →4.0.30319
X-Powered-By →ASP.NET
{"EmpNumber":"104091"
 "MobileNumber":"1234567898"
 "IMEINumber":"123456789256543"
 "GPSLatitude":"47.54"
 "GPSLog"::56.543"
 "GPSLocation":"GOA"
 }

I saw the comments on this link, and tried with all the solutions, but nothing have worked. What am I doing wrong??

Roysh
  • 1,542
  • 3
  • 16
  • 26

1 Answers1

0

Issue resolved. Comma was missing on JSON parameters,and problem got resolved.