REST API - Working Cross Domain JavaScript Example?
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:
1