Talk:Cover Art Archive/API

From MusicBrainz Wiki

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


 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:

   public static string GetReleaseCover(string title)
       string json = string.Empty;
       string artistlookupurl = "";
       /////// Look up info on selection from MusicBrainz ///////////
       Uri uri = new Uri(artistlookupurl);
           WebRequest request = WebRequest.Create(uri);
           WebResponse response = request.GetResponse();
           // Display status
           // 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;