I'm getting the below error while sending request to cloudsight api
{"error":{"image":["at least one of image or remote_image_url must be set"]}}
Can you please let me know what is missing.
Code snippet:
var xhr = new XMLHttpRequest();
var url = "http://api.cloudsightapi.com/image_requests";
xhr.open("POST", url, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.setRequestHeader('authorization', 'CloudSight <MY_API_KEY>');
xhr.setRequestHeader('cache-control', 'no-cache');
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myArr = JSON.parse(this.responseText);
alert(http.responseText);
}
};
xhr.send(JSON.stringify({"remote_image_url":"http://englishbookgeorgia.com/blogebg/wp-content/uploads/2015/08/husky.jpg" ,"locale":"en_US"}));
You'll want to use the v1 api that is documented here: https://cloudsight.docs.apiary.io/#reference/0/images-collection
Here is the corrected block using the v1 API.
The v0 api that you were using requires a root image object in the JSON, so:
Which is the reason for the error.