I am trying to call the api TextRazor (https://www.textrazor.com/docs/rest#introduction) which has examples in curl, php, python and Java. However I would like to do it with jquery ajax.
On the website we can see an example in curl:
curl -X POST \
-H "x-textrazor-key: YOUR_API_KEY" \
-d "extractors=entities,entailments" \
-d "text=Spain's stricken Bankia expects to sell off its vast portfolio of industrial holdings that includes a stake in the parent company of British Airways and Iberia." \
https://api.textrazor.com/
Here is how I am working to pass it through ajax
var txt = "Spain's stricken Bankia expects to sell off its vast portfolio of industrial holdings that includes a stake in the parent company of British Airways and Iberia.";
$.ajax({
url: "https://api.textrazor.com/",
type: "POST",
headers: {
"x-textrazor-key": "my-api-key"
},
data: {
extractors: 'entities',
text: txt
},
success: function(data) {
console.log(data);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
But all the time is sending 400 (Bad Request) error which means that the syntax is wrong.