4

I used this code :

    (function($){
    var albumID = 'NNbeO';
    var albumAPI = "https://api.imgur.com/3/album/" + albumID + "/images";

    $.ajax({
        url: albumAPI,
        headers:{
            'Authorization':'xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
        },
        type: 'GET',
        dataType: 'json',
        success: function(data) { 

            alert(data.data[0].link);

        },
        error: function() { console.log("ERRORZ"); }
    });
})(jQuery);

But I got this error :

 {
      "data": {
        "error": "Malformed auth header",
        "request": "\/3\/album\/NNbeO\/images",
        "method": "GET"
      },
      "success": false,
      "status": 403
    }
T3KBAU5
  • 1,861
  • 20
  • 26
Arif
  • 6,094
  • 4
  • 49
  • 81

1 Answers1

3

I got my solution. It works fine now. Below is my working code. It's problem was, I've not added Client-ID text with Authorization headers.:

(function($){
var albumID = 'NNbeO';
var albumAPI = "https://api.imgur.com/3/album/" + albumID + "/images";

  $.ajax({
      url: albumAPI,
      headers:{
          'Authorization':'Client-ID xxxxxxxxxxxxx'
      },
      type: 'GET',
      dataType: 'json',
      success: function(data) { 

          alert(data.data[0].link);

      },
      error: function() { console.log("ERRORZ"); }
  });

})(jQuery);
Arif
  • 6,094
  • 4
  • 49
  • 81