lundi 26 mars 2018

Postman Testing with Complex data type

I am new to Web API and trying learn how to debug Web API with POSTMAN.It is working with GET request only POST request has some trouble. I am not able to trouble shoot what extractly the error is.

 public HttpResponseMessage StudentDetails(Student data)
        {

            return new HttpResponseMessage()
            {
                Content = new StringContent(JArray.FromObject(data).ToString(), Encoding.UTF8, "application/json")
            };

        }

And Student Class is  as below.                                                                 public class Student
    {
        public int StudentId { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public string SSN { get; set; }
        public string PersonalEmail { get; set; }

    }


And I am trying to test the above action in POSTMAN. I added Content-Type as "application-json" and passing JSON as below . 
{
  StudentId :1
   FirstName : 'SINI'   ,
   LastName :'A',
   SSN : '7894300',
   PersonalEmail: 'sini@gmail.com'
}

And In the POSTMAN, I gave the below URL : 
http://localhost:60893/WebAPIDemo/api/Student

But it is giving me "The resource cannot be found".

Thanks




Aucun commentaire:

Enregistrer un commentaire