Talk:Cover Art Archive/API

From MusicBrainz Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Why can I not get back the JSON result as of this jQuery function:

$.getJSON("http://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd",

 function (data) {
    alert("getjson succeeded " );

});

It works if I first download the data and store it on my server and then us my server's url.

If I define a .NET page Web service, and then inside of that method retrieve the JSON via a WebRequest it works as so:

[System.Web.Services.WebMethod]
   public static string GetReleaseCover(string title)
   {
       string json = string.Empty;
      
       string artistlookupurl = "http://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd";
       /////// Look up info on selection from MusicBrainz ///////////
       Uri uri = new Uri(artistlookupurl);
       try
       {
           WebRequest request = WebRequest.Create(uri);
           WebResponse response = request.GetResponse();
           // Display status
           Console.WriteLine(((HttpWebResponse)response).StatusDescription);
           // Get the stream containing content returned by the server.
           Stream dataStream = response.GetResponseStream();
           // Open the stream using a StreamReader for easy access.
           StreamReader reader = new StreamReader(dataStream);
           // Read the content.
           json = reader.ReadToEnd();
       }
       catch ...
       return json;
    }