troubleshooting Question

Dot net core api is not getting value

Avatar of yadavdep
yadavdepFlag for India asked on
ASP.NETJSON* .net core
9 Comments1 Solution48 ViewsLast Modified:
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);
        }
    }
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros