Status code 405 (Method Not Allowed)

Problem

I'm new to AngularJs and Ionic. Building a schedule app just to practice so please go easy on me.

I don't know why I'm getting this 405 response. I tried to do a GET request with postman with the same information and it worked, but it doesn't work with my AngularJs code.

NOTE: I changed my access token (From UW) for safety.

Here's postman:

enter image description here

Here's my angular service:

enter image description here

and here's the error I'm getting when I run the ionic app:

enter image description here

Problem courtesy of: ln206

Solution

You have a cross origin policy problem. Add these headers to your webserver and you should be all set:

Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS

Access-Control-Allow-Origin: *

Access-Control-Allow-Headers: Content-Type

Don't forget to modify scope to suit your need.

== update ==

I just checked the link. The server is IIS 8.5

So I think this link you may find it helpful: http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api

Solution courtesy of: TLJ

Discussion

A 405 is a problem with the server angular is trying to talk to. Essentially, the request you made was matched to a route, but your server will not allow that route to execute.

Specifically, for your problem (and this is just my best assumption) ws.admin.washington.edu requires users to sign in. Your request is not authenticated.

Discussion courtesy of: Daniel Jamrozik

This recipe can be found in it's original form on Stack Over Flow.