Postman ошибка 405

Postman Community

Loading

--AAA
Content-Type: application/json
Content-Disposition: form-data


{
    "emailSubject": "Envelope Create - PDF PARTIAL Transform - MM Ind_Agency_Agree",
    "emailBlurb": "PDF PARTICIAL Transform",
    "status": "created",
    "compositeTemplates": 
    [{
            "inlineTemplates": 
            [{
                    "sequence": "1",
                    "recipients": {
                           "signers": 
                           [{
                                    "name": "Principal First And Last Names HERE",
                                    "email": "mittal.soniya3@gmail.com",
                                    "recipientId": "1",
                                    "routingOrder": "1",
                                    "clientUserId":"1234",
                                    "tabs":{
                                         "signHereTabs": [{
                                         "tabLabel":"Principal_eSignSignHere"
                                            }],
                                         "dateSignedTabs": [{
                                            "tabLabel": "FR2050IA_Principal_Date_eSignDateSigned"
                                            }],
                                         "textTabs": [
                                             {
                                               "tabLabel": "Principal1_Name",
                                               "value": "Joe Smith",
                                             }]
                                }

                        }],
                        "carbonCopies": [{
                            "email": "rishumittal.mittal3@gmail.com",
                            "name": "Lumari Vazquez",
                            "recipientId": "3",
                            "routingOrder": "3"
                        }]            
                  }  
            }],
            "document": {
              "name": "IM Agreement Individual-Gavin Moore Fran List TIC IM.pdf",
              "documentId": "1",
              "transformPdfFields": true
            }
    }]
}

Hello kulak-daria**,**

The “405 Method Not Allowed” error occurs when the server is configured in a way that does not allow you to perform a specific action for a particular endpoint (URL). It’s an HTTP response status code that indicates that the request method is known by the server but is not supported by the target resource (your request URL).

There are multiple causes for this error, but most commonly, this is caused by the server (endpoint URL) configuration.

  1. Firstly, You want to confirm which methods are supported for each endpoint and ensure that the POST method is configured. Ensure that your baseURL variable associated with your POST method is point to https://petstore3.swagger.io/api/v3
    (as highlighted in my screenshot below, as I was unable to reproduce this issue)

  2. Secondly, you want to confirm the then request URL is written correctly for the POST request (confirm it has no trailing spaces for example).

  3. Lastly, test if your POST request succeeds outside Postman; Send a request using cURL in your terminal. To do this, copy the cURL code generated by your request, paste it into your terminal, and send the request.

I have also referenced a discussion about this response in our Community: https://community.postman.com/t/405-method-not-allowed/16743/3 which has some additional troubleshooting steps you may try.

I hope that this information is helpful, and I have included an export of my working collection based on Swagger PetStore documentation — should you wish to test the POST method to «Add a new pet to the store»

via @loutsiros | Postman Support

  • Remove From My Forums
  • Question

  • Hi All,

       I have created delete,put method using WebAPI. While calling the method from postman i am getting the method not allowed. I have done R&D and applied the changes but no luck. Please help me on this.

     //[System.Web.Http.AcceptVerbs(«GET», «POST»,»DELETE»)]
            //[System.Web.Http.HttpDelete]
            public void Delete(int id)
            {
                using (EmployeeDBEntities entities = new EmployeeDBEntities())
                {
                    entities.emps.Remove(entities.emps.FirstOrDefault(e=>id==e.id));
                    entities.SaveChanges();

                }

            }

    settings in webconfig

    <system.webServer>
        <validation validateIntegratedModeConfiguration=»false» />
        <modules runAllManagedModulesForAllRequests=»true»>
          <remove name=»WebDAVModule» />
        </modules>
        <handlers>
          <remove name=»WebDAV» />
          <remove name=»ExtensionlessUrlHandler-Integrated-4.0″ />
          <remove name=»OPTIONSVerbHandler» />
          <remove name=»TRACEVerbHandler» />
          <add name=»ExtensionlessUrlHandler-Integrated-4.0″ path=»*.» verb=»*» type=»System.Web.Handlers.TransferRequestHandler» preCondition=»integratedMode,runtimeVersionv4.0″ />

        
        </handlers>
      </system.webServer>

Answers

  • If you don’t give a HTTP verb, then it’s an implied ‘Get’. On a ‘Delete’ named only WebAPI controller method, then you need the ‘Delete’ verb only. If you were  inserting or updating data, you would use Post or Put — Put if the method name is ‘Put’
    only. 

    ASP.NET WebAPI has a forum in ASP.NET forums.

    http://forums.asp.net/

    Also you should try to implement some kind of SoC where no direct data access is being done from a controller. 

    https://en.wikipedia.org/wiki/Separation_of_concerns

    using DAL;
    using Entities;
    using Microsoft.AspNetCore.Mvc;
    using System.Collections.Generic;
    
    namespace ProgMgmntCore2Api.Controllers
    {
        [Produces("application/json")]
        [Route("api/[controller]")]
        [ApiController]
    
        public class TaskController : ControllerBase
        {
            private readonly IDaoTask _daoTask;
    
            public TaskController(IDaoTask daoTask)
            {
                _daoTask = daoTask;
            }
    
            [HttpGet]
            [Route("GetTaskById")]
            public DtoTask GetTaskById(int id)
            {
                return _daoTask.GetTaskById(id);
            }
    
            [HttpGet]
            [Route("GetTasksByProjId")]
            public List<DtoTask> GetTasksByProjectId(int id)
            {
                return _daoTask.GetTasksByProjectId(id);
            }
    
            [HttpPost]
            [Route("CreateTask")]
            public void CreateTask(DtoTask dto)
            {
                _daoTask.CreateTask(dto);
            }
    
            [HttpPost]
            [Route("UpdateTask")]
            public void UpdateTask(DtoTask dto)
            {
                _daoTask.UpdateTask(dto);
            }
    
            [HttpPost]
            [Route("DeleteTask")]
            public void DeleteTask(DtoId dto)
            {
                _daoTask.DeleteTask(dto.Id);
            }
        }
    }

    • Proposed as answer by

      Sunday, March 29, 2020 2:37 AM

    • Marked as answer by
      KareninstructorMVP
      Tuesday, April 14, 2020 2:56 PM

on my .Net Web Api, I have an entity model, request model and response model for each database table. When i make a post request to MedTestOrder, i receive a 405 error, but other entities are working fine. I will post code snippets of MedTestOrder entity model, request model, response model, controller and service. The models contain foreign keys and I suspect my error could be from there. I might be wrong or not. I just need help.

1 — Entity Model

namespace Africanbiomedtests.Entities
{
        public class MedTestOrder
    {
        [Key]
        public int Id { get; set; }
        public int? MedTestId { get; set; }
        [ForeignKey("MedTestId")]
        public MedTest MedTest { get; set; }
        public int? healthcareProviderId { get; set; }
        [ForeignKey("healthcareProviderId")]
        public HealthcareProvider healthcareProvider { get; set; }
        public int? accountId { get; set; }
        [ForeignKey("accountId")]
        public Account Account { get; set; }
        public int? newbornId { get; set; }
        [ForeignKey("newbornId")]
        public Newborn Newborn { get; set; }
        public string PaymentStatus { get; set; }
        public Boolean CompletionStatus { get; set; }
        public DateTime DateCreated { get; set; }
        public DateTime DateCompleted { get; set; }
        public DateTime? Updated { get; set; }

    }

}

2 — Api Request Model

namespace Africanbiomedtests.Models.MedTestsOrder
{
    public class MedTestsOrderCreateRequest
    {
        [Required]
        public MedTest MedTest { get; set; }

        public HealthcareProvider healthcareProvider { get; set; }

        public Account Account { get; set; }

        public Newborn Newborn { get; set; }

        [Required]
        public string PaymentStatus { get; set; }
        public Boolean CompletionStatus { get; set; }

        [Required]
        public DateTime DateCreated { get; set; }

    }
}

3 — Response Model

namespace Africanbiomedtests.Models.MedTestsOrder
{
    public class MedTestsOrderResponse
    {
        public int Id { get; set; }
        public MedTest MedTest { get; set; }
        public HealthcareProvider healthcareProvider { get; set; }
        public Account Account { get; set; }
        public Newborn Newborn { get; set; }
        public string PaymentStatus { get; set; }
        public Boolean CompletionStatus { get; set; }
        public DateTime DateCreated { get; set; }
        public DateTime DateCompleted { get; set; }

    }
}

4 — Controller

[Authorize]
[HttpPost("create")]
public ActionResult<MedTestsOrderResponse> Create(MedTestsOrderCreateRequest model)
{
    var medTestOrder = _medTestOrderService.Create(model);
    return Ok(medTestOrder);
}

5 — Service

public MedTestsOrderResponse Create(MedTestsOrderCreateRequest model)
        {

            // map model to new account object
            var medTestOrder = _mapper.Map<MedTestOrder>(model);
            medTestOrder.DateCreated = DateTime.UtcNow;


            // save account
            _context.MedTestOrder.Add(medTestOrder);
            _context.SaveChanges();

            return _mapper.Map<MedTestsOrderResponse>(medTestOrder);
        }

6 — Postman JSON request

{
    "medTestId": 3,
    "healthcareProviderId": 3,
    "accountId": 1004,
    "newbornId": 1,
    "paymentStatus": "Complete Payment",
    "completionStatus": "1",
    "dateCompleted": "01/14/2021"
}

I would really appreciate any help right now

Понравилась статья? Поделить с друзьями:
  • Preload adjuster ktm 1290 ошибка
  • Postimg ошибка 503
  • Pozis винный шкаф ошибка ah
  • Postimage ошибка 503
  • Pozis paracels ошибка 255