Here is the situation. With the following code below, connect to the API using Ajax. However, I'm getting the following messages:
OPTIONS [URL] 404 (Not Found)
and getting the statusText: "error" when I try to connect to the API.
Here is the code that I'm currently using:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$.ajax({
url: "URL That I'm connecting to,
beforeSend: function(xhr) {
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
},
dataType: "json",
data: {
client_id: "",
client_secret: "",
grant_type: "client_credentials"
},
type: "POST",
success: function(response) {
token = response.access_token;
expiresIn = response.expires_in;
},
error: function(errorThrown) {
console.log(errorThrown);
}
});
</script>
Any help would be appreciated.
Thank you, Kevin