Avatar of yadavdep
yadavdep
Flag for India

asked on 

Dot net core api is not getting value

I have a dot net core API which has a method
Now from PostMan when I am testing this api and sends this json data
"{
    "Username": "xxx116@clsdsddp.com"
}"
I always gets null in the username.

I have set the content type to application/json.

Not sure where I am making the mistake



using Autofac.Multitenant;
using CLIPITC.CORE.Helper;
using CLIPITC.CORE.Middlewares;
using CLIPITC.Repositories.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serilog;
using System;
using System.Threading.Tasks;
using Utils;
using static System.Net.WebRequestMethods;

namespace CLIPITC_CORE.Controllers
{
    [ServiceFilter(typeof(CustomActionFilter))]
    [Produces("application/json")]
    [Route("~/api/[Action]")]
    public class AccountController : Controller
    {
        IAccountRepository _accountRepo;
        public AccountController(IAccountRepository accountRepo, ITenantIdentificationStrategy service)
        {
            _accountRepo = accountRepo;
            (service as MultitenantResolver).Init(_accountRepo);
        }

        [HttpPut]
        public ActionResult RemoveMobileIDForUser(string Username)
        {
            
            if (Username.IsNull())
                return new BadRequestObjectResult("UserName Can't be empty");

            var response = _accountRepo.RemoveRememberMeOptionFromUser(Username);
            return new ObjectResult(response);
        }
    }
}

Open in new window

JSONASP.NET* .net core

Avatar of undefined
Last Comment
yadavdep

8/22/2022 - Mon