You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

REST API - Working Cross Domain JavaScript Example?

Accepted answer
18
Views
3
Comments
edited Apr 14, 2017 12:02AM in Integrations and APIs 3 comments

Content

Hi all,

I am familiarizing myself with the REST API, and it seems very robust. However, I'm noticing that CORS are not enabled, and that basic authorization fails in JSON. JSONP has its own set of problems. Any tips or advice? Or, is JavaScript not well suited to this API and PHP is the method of choice?

Thanks a lot,

Carl

 

 

Code Snippet

             <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> 
<script>
var myOracleURL = "https://<site>.custhelp.com/services/rest/connect/v1.3/accounts/62";
var username = "myusername";
var password = "mypassword";

$.ajax({
    type: "GET",
    url: myOracleURL,
    beforeSend : function(xhr) {
        var credentials = btoa(username + ":" + password);
        xhr.setRequestHeader("Authorization", "Basic " + credentials);
    },
    dataType: "json",
    success: function(data) {
        console.log(data);
    },
    error:

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!