Why is my JavaScript API call returning a 400 error?
I have an API call that is receiving the "Failed to load Resource" 400 error. I have tried deleting cookies and cache and using a different browser. I also removed an image when I saw that image size could be the issue. I read about the need for HTTP headers, but did not understand where that would go in my code or what it would look like. Any assistance would be greatly appreciated! Here is my JS:
const app = document.getElementById('root');
const container = document.createElement('div');
container.setAttribute('class', 'container');
app.appendChild(container);
var request = new XMLHttpRequest();
request.open('GET', 'https://www.themuse.com/api/public/jobs', true);
request.onload = function ()
// Begin accessing JSON data here
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400)
data.forEach(job =>
const card = document.createElement('div');
card.setAttribute('class', 'card');
const h1 = document.createElement('h1');
h1.textContent = job.title;
const p = document.createElement('p');
job.description = job.description.substring(0, 300);
p.textContent = `$job.description...`;
container.appendChild(card);
card.appendChild(h1);
card.appendChild(p);
);
else
const errorMessage = document.createElement('marquee');
errorMessage.textContent = `Darn, it's not working!`;
app.appendChild(errorMessage);
request.send();
javascript api http-status-code-400
add a comment |
I have an API call that is receiving the "Failed to load Resource" 400 error. I have tried deleting cookies and cache and using a different browser. I also removed an image when I saw that image size could be the issue. I read about the need for HTTP headers, but did not understand where that would go in my code or what it would look like. Any assistance would be greatly appreciated! Here is my JS:
const app = document.getElementById('root');
const container = document.createElement('div');
container.setAttribute('class', 'container');
app.appendChild(container);
var request = new XMLHttpRequest();
request.open('GET', 'https://www.themuse.com/api/public/jobs', true);
request.onload = function ()
// Begin accessing JSON data here
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400)
data.forEach(job =>
const card = document.createElement('div');
card.setAttribute('class', 'card');
const h1 = document.createElement('h1');
h1.textContent = job.title;
const p = document.createElement('p');
job.description = job.description.substring(0, 300);
p.textContent = `$job.description...`;
container.appendChild(card);
card.appendChild(h1);
card.appendChild(p);
);
else
const errorMessage = document.createElement('marquee');
errorMessage.textContent = `Darn, it's not working!`;
app.appendChild(errorMessage);
request.send();
javascript api http-status-code-400
1
The error isNot a valid argument for 'page'
, is the API being used correctly?
– Hodrobond
Nov 15 '18 at 22:39
themuse.com/developers/api/v2 On the docs for that endpoint it says the page number is required, you will have to send that up for a valid response.
– Sunny Wong
Nov 15 '18 at 22:49
add a comment |
I have an API call that is receiving the "Failed to load Resource" 400 error. I have tried deleting cookies and cache and using a different browser. I also removed an image when I saw that image size could be the issue. I read about the need for HTTP headers, but did not understand where that would go in my code or what it would look like. Any assistance would be greatly appreciated! Here is my JS:
const app = document.getElementById('root');
const container = document.createElement('div');
container.setAttribute('class', 'container');
app.appendChild(container);
var request = new XMLHttpRequest();
request.open('GET', 'https://www.themuse.com/api/public/jobs', true);
request.onload = function ()
// Begin accessing JSON data here
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400)
data.forEach(job =>
const card = document.createElement('div');
card.setAttribute('class', 'card');
const h1 = document.createElement('h1');
h1.textContent = job.title;
const p = document.createElement('p');
job.description = job.description.substring(0, 300);
p.textContent = `$job.description...`;
container.appendChild(card);
card.appendChild(h1);
card.appendChild(p);
);
else
const errorMessage = document.createElement('marquee');
errorMessage.textContent = `Darn, it's not working!`;
app.appendChild(errorMessage);
request.send();
javascript api http-status-code-400
I have an API call that is receiving the "Failed to load Resource" 400 error. I have tried deleting cookies and cache and using a different browser. I also removed an image when I saw that image size could be the issue. I read about the need for HTTP headers, but did not understand where that would go in my code or what it would look like. Any assistance would be greatly appreciated! Here is my JS:
const app = document.getElementById('root');
const container = document.createElement('div');
container.setAttribute('class', 'container');
app.appendChild(container);
var request = new XMLHttpRequest();
request.open('GET', 'https://www.themuse.com/api/public/jobs', true);
request.onload = function ()
// Begin accessing JSON data here
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400)
data.forEach(job =>
const card = document.createElement('div');
card.setAttribute('class', 'card');
const h1 = document.createElement('h1');
h1.textContent = job.title;
const p = document.createElement('p');
job.description = job.description.substring(0, 300);
p.textContent = `$job.description...`;
container.appendChild(card);
card.appendChild(h1);
card.appendChild(p);
);
else
const errorMessage = document.createElement('marquee');
errorMessage.textContent = `Darn, it's not working!`;
app.appendChild(errorMessage);
request.send();
javascript api http-status-code-400
javascript api http-status-code-400
asked Nov 15 '18 at 22:31
user9905066
1
The error isNot a valid argument for 'page'
, is the API being used correctly?
– Hodrobond
Nov 15 '18 at 22:39
themuse.com/developers/api/v2 On the docs for that endpoint it says the page number is required, you will have to send that up for a valid response.
– Sunny Wong
Nov 15 '18 at 22:49
add a comment |
1
The error isNot a valid argument for 'page'
, is the API being used correctly?
– Hodrobond
Nov 15 '18 at 22:39
themuse.com/developers/api/v2 On the docs for that endpoint it says the page number is required, you will have to send that up for a valid response.
– Sunny Wong
Nov 15 '18 at 22:49
1
1
The error is
Not a valid argument for 'page'
, is the API being used correctly?– Hodrobond
Nov 15 '18 at 22:39
The error is
Not a valid argument for 'page'
, is the API being used correctly?– Hodrobond
Nov 15 '18 at 22:39
themuse.com/developers/api/v2 On the docs for that endpoint it says the page number is required, you will have to send that up for a valid response.
– Sunny Wong
Nov 15 '18 at 22:49
themuse.com/developers/api/v2 On the docs for that endpoint it says the page number is required, you will have to send that up for a valid response.
– Sunny Wong
Nov 15 '18 at 22:49
add a comment |
1 Answer
1
active
oldest
votes
If you try loading https://www.themuse.com/api/public/jobs in a browser you a 400 error along with the following error message:
"code": 400, "error": "Not a valid argument for 'page'"
That page requires you to supply it with a non-null variable called page
via your GET
request.
If you load the page as https://www.themuse.com/api/public/jobs?page=1 (eg) instead you can successfully load the data and your problem disappears!
The addition of /jobs?/page=1 cleared the error! Thanks so much. Now, onto the next error message. :)
– user9905066
Nov 16 '18 at 14:45
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328794%2fwhy-is-my-javascript-api-call-returning-a-400-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you try loading https://www.themuse.com/api/public/jobs in a browser you a 400 error along with the following error message:
"code": 400, "error": "Not a valid argument for 'page'"
That page requires you to supply it with a non-null variable called page
via your GET
request.
If you load the page as https://www.themuse.com/api/public/jobs?page=1 (eg) instead you can successfully load the data and your problem disappears!
The addition of /jobs?/page=1 cleared the error! Thanks so much. Now, onto the next error message. :)
– user9905066
Nov 16 '18 at 14:45
add a comment |
If you try loading https://www.themuse.com/api/public/jobs in a browser you a 400 error along with the following error message:
"code": 400, "error": "Not a valid argument for 'page'"
That page requires you to supply it with a non-null variable called page
via your GET
request.
If you load the page as https://www.themuse.com/api/public/jobs?page=1 (eg) instead you can successfully load the data and your problem disappears!
The addition of /jobs?/page=1 cleared the error! Thanks so much. Now, onto the next error message. :)
– user9905066
Nov 16 '18 at 14:45
add a comment |
If you try loading https://www.themuse.com/api/public/jobs in a browser you a 400 error along with the following error message:
"code": 400, "error": "Not a valid argument for 'page'"
That page requires you to supply it with a non-null variable called page
via your GET
request.
If you load the page as https://www.themuse.com/api/public/jobs?page=1 (eg) instead you can successfully load the data and your problem disappears!
If you try loading https://www.themuse.com/api/public/jobs in a browser you a 400 error along with the following error message:
"code": 400, "error": "Not a valid argument for 'page'"
That page requires you to supply it with a non-null variable called page
via your GET
request.
If you load the page as https://www.themuse.com/api/public/jobs?page=1 (eg) instead you can successfully load the data and your problem disappears!
answered Nov 15 '18 at 22:46
seisvelasseisvelas
2,03911229
2,03911229
The addition of /jobs?/page=1 cleared the error! Thanks so much. Now, onto the next error message. :)
– user9905066
Nov 16 '18 at 14:45
add a comment |
The addition of /jobs?/page=1 cleared the error! Thanks so much. Now, onto the next error message. :)
– user9905066
Nov 16 '18 at 14:45
The addition of /jobs?/page=1 cleared the error! Thanks so much. Now, onto the next error message. :)
– user9905066
Nov 16 '18 at 14:45
The addition of /jobs?/page=1 cleared the error! Thanks so much. Now, onto the next error message. :)
– user9905066
Nov 16 '18 at 14:45
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328794%2fwhy-is-my-javascript-api-call-returning-a-400-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
The error is
Not a valid argument for 'page'
, is the API being used correctly?– Hodrobond
Nov 15 '18 at 22:39
themuse.com/developers/api/v2 On the docs for that endpoint it says the page number is required, you will have to send that up for a valid response.
– Sunny Wong
Nov 15 '18 at 22:49