0

I am trying to use the Yoda speak api. Here is my fiddle of it:

  • http://jsfiddle.net/Dansker/tdhnmmye/

    $.ajax({
        url: 'https://yoda.p.mashape.com/yoda', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile
        type: 'GET', // The HTTP Method
        data: {sentence: $("#boxArea").val()}, // Additional parameters here
        datatype: 'json',
        success: function (data) {
            alert(data);
        },
        error: function (err) {
            alert(err);
        },
        beforeSend: function (xhr) {
            xhr.setRequestHeader("X-Mashape-Authorization", "<RvyROurVRvmshRzDcAtXABdytvkDp1MtroWjsnXo8Dcs9Dq6SB>"); // Enter here your Mashape key
        }
    });});});
    

I think the code all works but I keep getting 403 errors saying my key does not work. I keep resetting my key but it keeps saying that it does not work. Is it the key or something else? Also the "yoda speak" will be displayed as alert?

  • Remove the < > operators from your key. Also assuming this is your actual mashape key you wouldn't want to post it here for everyone to see. As a side note I have been using the above API for a while. Combined with Mashape issues and the actual API endpoint down time I had significant issues and so switched to http://funtranslations.com/api/yoda and it is working like a charm. – dors Apr 06 '16 at 18:30

1 Answers1

0

Just a guess, but have you tried removing the outer angle brackets?

Try changing this:

xhr.setRequestHeader("X-Mashape-Authorization", "<RvyROurVRvmshRzDcAtXABdytvkDp1MtroWjsnXo8Dcs9Dq6SB>");

To this:

xhr.setRequestHeader("X-Mashape-Authorization", "RvyROurVRvmshRzDcAtXABdytvkDp1MtroWjsnXo8Dcs9Dq6SB");
Daryn
  • 3,394
  • 5
  • 30
  • 41