Hello
I can make an entity search request just fine by navigating to this...
https://api.thomsonreuters.com/permid/search?q=TRI&access-token=MY_ACCESS_TOKEN
...which displays some nice JSON in my browser.
Question is, how to I make this request programmatically using client-side javascript?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
var accessToken = "MY_ACCESS_TOKEN"; var myURL = "https://api.thomsonreuters.com/permid/search?q=TRI"; $.ajax({ type: 'GET', format: 'JSON', dataType: 'JSON', url: myURL, headers: { 'access-token': accessToken }, success: function(data, status) { console.log(data); } });
Predictably enough this returns the standard 'Access-Control-Allow-Origin' message:
XMLHttpRequest cannot load https://api.thomsonreuters.com/permid/search?q=TRI. Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://developer.permid.org' that is not equal to the supplied origin. Origin 'http://localhost:9999' is therefore not allowed access.
What's the solution, please? Is it necessary to use a JSONP request perhaps, or is there some syntactical problem with my JSON AJAX request, e.g. the header is not specified correctly?
On the portal there are various code samples including JAVA but I don't see one for JS.