"Method Not Found" and "Method Not Allowed" using WebAPI and POST

0

I am developing a picking software where the user from a sales order (order) creates a pick list (which contain the products that the warehouse clerk will fetch and then transport the person to the house ).

Whenever I try to create a new pick list the response always comes false .

My code is as follows:

Client side - creation and submission to the Information WebAPI

public async Task<bool> AddTarefa(ListasPicking listaPickingAdd) 
    {
        String listaparaAdicionar = listaPickingAdd.idLista + ";" + listaPickingAdd.IDordemVenda + ";" + listaPickingAdd.peso + ";" + listaPickingAdd.itens;
        HttpResponseMessage response = await cliente.PutAsJsonAsync("api/ListasPicking/", listaparaAdicionar);


        return response.IsSuccessStatusCode; // esta resposta vem sempre false.

This variable response always came with false and with one of these errors.

  

Method Not Allowed

     

Method Not Found

After having changed a few lines of code gives this:

  

Internal Server Error

WEBAPI side

    private PrimaveraRestContext primContext = new PrimaveraRestContext();

    //PUT: api/ListasPicking
    [ResponseType(typeof (ListasPicking))]
    [HttpPut]
     public IHttpActionResult PutLista ([FromBody] String lista)
    {
        if(!ModelState.IsValid)
        {
            return BadRequest(ModelState);
        }

        String[] result = lista.Split(';');
        ListasPicking novaLista = new ListasPicking();
        novaLista.idLista=result[0];
        novaLista.IDordemVenda = result[1];
        string lista_peso_converttoDouble = result[2];
        novaLista.peso = Convert.ToDouble(lista_peso_converttoDouble);
        string lista_items_converttoInt = result[3];
        novaLista.itens = Convert.ToInt32(lista_items_converttoInt);

        primContext.ListasPickingGet.Add(novaLista);
        primContext.SaveChanges();

        return null;


    }

Web.Config

    <?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="PrimaveraRest" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

  <system.webServer>
    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>

  <system.web>
    <compilation>
      <assemblies>
        <add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
  </system.web>
</configuration>
    
asked by anonymous 24.05.2017 / 22:05

0 answers