|
FRCAPI Response for preflight has invalid HTTP status code 405 (#production_server #JavaScript #novice)
|
02/24/2016 11:31 PM
post4817
|
FRCAPI Response for preflight has invalid HTTP status code 405 (#production_server #JavaScript #novice)
No problems with the mock server, however the production server is giving me the following message:
"XMLHttpRequest cannot load https://frc-api.firstinspires.org/v2.0/2016/matches/WEEK0. Response for preflight has
invalid HTTP status code 405."
Notes:
I'm using the Chrome extension "Allow-Control-Allow-Origin" to enable CORS
I receive the same message regardless of whether file is open in my browser or hosted on AWS.
Error is the same with or without the commented headers below.
Code: (JavaScript)
function sendRequest(){
var username = document.getElementById('Username').value;
var authorizationKey = document.getElementById('AuthorizationKey').value;
var key = btoa(username + ":" + authorizationKey);
var request = new XMLHttpRequest();
var url = "https://frc-api.firstinspires.org/v2.0/2016/matches/WEEK0";
request.open('GET', url);
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('Authorization', 'Basic ' + key);
// request.setRequestHeader('Access-Control-Allow-Origin', '*');
// request.setRequestHeader('Access-Control-Allow-Headers', 'Content-Type');
// request.setRequestHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
request.onreadystatechange = function () {
if (this.readyState === 4) {
var myArr = JSON.parse(this.responseText);
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
}
request.send();
Question:
What am I doing wrong?
|
|
|