Postman PUT with Bearer Token doesn't work

572 views Asked by At

I'm try to make an PUT request using Bearer Token but did not work. The only method giving this problem is the PUT method, all other are working fine. Anyone know why ?

enter image description here

1

There are 1 answers

0
federico scamuzzi On BEST ANSWER

it looks as CORS problem... try to to this .. in your webconfig.xml:

<system.webServer>
    <modules>
      <remove name="FormsAuthentication" />
    </modules>
    <handlers>
      <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>

And then in your StartUp.cs files:

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Owin;
using Owin;
using Microsoft.Owin.Cors;

[assembly: OwinStartup(typeof(DipendentiStatali.API.Startup))]

namespace DipendentiStatali.API
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {




            app.UseCors(CorsOptions.AllowAll); //<--ALLOW CORS FOR ALL OR FOR WHAT HOST YOU WANT
            ConfigureAuth(app);
        }
    }
}

Then try to send your request as JSON instead of xx-form-urlencoded