• Register
1 vote
70 views

Problem :

I keep on facing the below 403 error while performing the AJAX call to the API.

“403 forbidden: the server understood the request, but is refusing to fulfill it.”

Above error occurs usually in Microsoft Edge, but does not come up in IE, Chrome, Firefox or the Safari.

My page does not use the bootstrap, as I know that it can be caused by a page not been able to locate a .LESS files required. Also I have even tried to include the bootstrap to see if that resolved my issue – but it did not.

I am unable to find anything related by doing research on this. My code is exactly the same across all the various browsers and also the response/request headers match to one another - So is it the case that the POST request is sending the incorrect?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had the same issue and tried all the solutions which I knew, and neither of them worked actually after long research I found the solution for the error as below:

Please include the credentials in the options as shown in below code snippet.

 

var dummyurl = 'https://dummy_url/_api/lists'
var myoptions = {
    headers: {"Accept": "application/json; odata=verbose"},
    credentials: 'include'
}

fetch(dummyurl, myoptions).then( 
    res => res.json().then(json => console.dir(json)) 
)

 

This works flawlessly for me.

9 7 4
38,600 points

Related questions

0 votes
1 answer 429 views
429 views
On trying to scrap a website for practice, but I kept on getting the HTTP Error 403 (does it think the user is a bot)? Here is the code: #import requests import urllib.request from bs4 import BeautifulSoup #from urllib import urlopen import re webpage = ... py", line 599, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden
asked Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 6 views
6 views
I have a function foo which makes an asynchronous request. How can I return the response/result from foo? I tried returning the value from the callback, as well as assigning the result to a local variable inside the function and returning that one, but none of those ways actually ... response; // return response; // <- I tried that one as well }); return result; // It always returns `undefined` }
asked Nov 10, 2020 Han Li 710 points
0 votes
1 answer 403 views
403 views
Problem : I have spent over the 10 hours in finding the exception or the special character to find in the code but I am unable to find it. I have already checked every similar messages in here. I am facing below error: Syntaxerror: json.parse: unexpected character at line 1 ... my form after that I am sending all the inputs to the main.js to validate it. So, I am just looking for the third-eye.
asked Dec 23, 2019 alecxe 7.5k points
0 votes
1 answer 15 views
15 views
Is there any tutorial that will show how to display database record without without pressing the submit button? For example, <select name="cars"> <option value="">Select a car:</option> <option value="1">Volvo</option> <option value="2">BMW</option> ... > </select> In this example, the user will select anything from the list and should automatically display the information based on the selection.
asked Oct 11, 2020 azriel 590 points
0 votes
1 answer 17 views
17 views
We had a online based survey company. We survey the market on the basis of user&rsquo;s opinion. we need to store the user&rsquo;s data and utilize the text data input. How can we do this using javascript ?
asked Sep 15, 2020 Daniel Anderson 4k points
0 votes
1 answer 10 views
0 votes
1 answer 10 views
10 views
Problem: I am very new to programming world. I have below HTML code and I want to submit it and save the form data with the help of javascript. <!DOCTYPE html> <html> <head>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width"> ... If I click on the submit button then the above forms data should be saved somewhere for the each and every user who fills and submits the data.
asked Jul 30, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 82 views
82 views
Problem : I am getting following error cross-origin request blocked: the same origin policy disallows reading the remote resource at
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
1 answer 20 views
20 views
Problem: I am facing below error while using the ngResource to call my REST API on Amazon Web Services: XMLHttpRequest cannot load http://server.apiurl.com:8000/s/login?login=facebook. Response to preflight request doesn't pass access control check: No 'Access-Control- ... be done so that I can fix above problem. I have already configured my server to accept the headers from the origin localhost.
asked Jul 15, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 9 views
9 views
Problem: I have a table for my recipe entry. I use also jquery to add dynamic fields. I want to save my data through ajax call. How will I do it? Here's my html code: <form method="post" action="#"> <label for="recipe_name">Recipe Name</label><br> <input type="text" name=" ... ); $('#entry').on("click", ".delete", function (e) { e.preventDefault(); $(this).closest('tr').remove(); }); </script>
asked Nov 12, 2020 Grace Butan 340 points