Unable to Post and Put via Postman RRS feed

  • Question

  • User-309523270 posted


    I'm trying to do an HttpPost and HttpPut in the Web-Api via Postman.

    It's returning a Response code: 404.  It's  adding a request(shown above the method name) but it doesn't go into the method body when I execute on debug mode.  No record is inserted either. 

    Here's the script:


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using myCMS.Business;
    using myCMS.Business.Repository;
    using Common;
    using Common.DTOs;
    using Common.Models ;
    using AutoMapper;
    using Newtonsoft.Json.Linq;
    using Newtonsoft.Json;
    //using System.Web.Http;

    namespace myCMSNet.WebApi.Controllers

            public class CodeTableController : Controller
            private readonly CodeTableRepository _CodeTableRepository;
            private readonly IMapper _mapper;

            public CodeTableController(CodeTableRepository aCodeTableRepository, IMapper mapper)
                _CodeTableRepository = aCodeTableRepository;
                _mapper = mapper;

            // GET: api/values
            public IEnumerable<string> Get()
                return new string[] { "value1", "value2" };

            public async Task<CodeTableAddVM> Get(string asCategory, string asCode)
                return await _CodeTableRepository.FindById(asCategory, asCode);

            public async Task<IActionResult> create(CodeTableAddVM oData)
                var res = await _CodeTableRepository.Create(oData);

                if (res == null)
                    return BadRequest();
                return Ok(res);

            public async Task<IActionResult> Put([FromBody] CodeTableAddVM oData)
                if (ModelState.IsValid)
                    var result = await _CodeTableRepository.Update(oData.Category, oData.Code, oData);
                    if (result == null)
                        return BadRequest();

                    return Ok(result);
                return BadRequest();



    Content-Type  :  application/json

    Body:  raw    JSON(application/json)
    "category" : "victim_category",
    "code" : "TEST",
    "value" : "TEST TEST TEST",
    "created_dt" : "3/12/2018",
    "created_by" : "1",
    "modified_dt" : "3/12/2018",
    "modified_by" : "1"

    Please advise.



    Monday, March 12, 2018 9:47 PM


  • User-309523270 posted

    I got it...I had the wrong URL

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 13, 2018 12:12 AM