ERROR 405 (Method Not Allowed)

360 views
Skip to first unread message

Lost in OWF

unread,
Oct 21, 2014, 1:01:45 PM10/21/14
to ozonepla...@googlegroups.com
I have a Web API running and I have an OWF widget running, the widget then calls the api's 'PUT' and I get this error
The requested resource does not support http method 'PUT'.
The 'POST' works fine but 'PUT' and 'DELETE' don't work? Is this an OWF issue?

Ross Pokorny

unread,
Oct 21, 2014, 1:10:11 PM10/21/14
to ozonepla...@googlegroups.com
You are not referring to the REST API of OWF itself, correct? Assuming you
are not, this is not an OWF issue. Are you in control of this REST API? If
so, inspect your server-side code to see what methods are allowed. If not,
contact the developer of the API or search for its documentation in order to
determine what methods are valid on what URLs.

Are the widget and the API running on the same domain? If not, communication
between the widget and the API will be more difficult. In this case you will
want to make sure that you enable CORS (supported in recent browsers only) or
one of several legacy mechanisms that can be used to support cross-domain
communication (JSONP, windowname, etc).

Ross Pokorny
OWF Developer

Lost in OWF

unread,
Oct 21, 2014, 1:20:11 PM10/21/14
to ozonepla...@googlegroups.com
Hi Ross, 

I don't believe that I am using the REST API of OWF itself, I am in control of the server side code,
I have checked to make sure that 'GET', 'POST', 'PUT', & 'DELETE' are all allowed, yet only 'GET' and 'POST' are working and 'PUT' and 'DELETE' are not allowed
<system.webServer>
    <httpProtocol>
      <customHeaders>
        ....
        <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>

The widget and API are not in the same domain but CORS is enabled 

Ross Pokorny

unread,
Oct 21, 2014, 2:05:15 PM10/21/14
to ozonepla...@googlegroups.com
Do you actually have code on the URL endpoint in question to handle a POST?

A good way to determine definitively if this is an OWF problem is to run your
widget on its own, outside of OWF. If you get the same problem, it is not an
OWF problem. You could also try calling the REST endpoint in question
manually from a REST development tool in order to help determine if it is a
problem with your server side code in general or only with the way it
interacts with the widget.

Ross Pokorny
OWF Developer
Message has been deleted

Lost in OWF

unread,
Oct 21, 2014, 2:21:30 PM10/21/14
to
Ross,

I got it fixed, it wasn't an OWF issue, it was a server side issue which I thought it might be, 
I added this function to the global.asax file
protected void Application_BeginRequest(object sender, EventArgs e)
        {
            //HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
            if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
            {
                HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache");
                //HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
                //HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
                HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
                HttpContext.Current.Response.End();
            }
        }
and it worked so I am now investigating as to why that worked and why my custom headers didn't work
<customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
        <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
      </customHeaders>

Reply all
Reply to author
Forward
0 new messages