Unable to verify the first certificate while testing POST API using Postman

Viewed 980

I am writing a POST API which needs authorization in order to post something. When I test the POST API, I get 200 OK status but It shows me home page(login page) in response. I have already disabled SSL Certificate verification.

Here is the controller

using GigHub.Models;
using Microsoft.AspNet.Identity;
using System.Web.Http;

namespace GigHub.Controllers
{
    [Authorize]  
    public class AttendancesController : ApiController
    {

        private ApplicationDbContext _context;

        public AttendancesController()
        {
            _context = new ApplicationDbContext();
        }



        [HttpGet]
        public IHttpActionResult GET()
        {
            return Ok("Hi there");

        }

        //POST API
        [HttpPost]
        public IHttpActionResult Attend([FromBody]int gigId)
        {
            var attendance = new Attendance()
            {
                GigId = gigId,
                AttendeeId = User.Identity.GetUserId()
            };

            _context.Attendances.Add(attendance);
            _context.SaveChanges();

            return Ok();
        }
    }
}

Here is the response and error I get, enter image description here

When I remove the [Authorize] code above class and test the get api, my api is working fine. The problem arised when I put [Authorize]

0 Answers
Related