public async Task <ArtistAlbumsHolder> GetArtistAlbums(string id, string offset = "0", string limit = "20")
        {
            using (var client = new HttpClient())
            {
                try
                {
                    spotifyKey = GetToken().Result;
                    string apilink = "https://api.spotify.com/v1/artists/" + id + "/albums?offset=" + offset + "&limit=" + limit + "&album_type=single,album,compilation,appears_on,ep";

                    var serializer = new DataContractJsonSerializer(typeof(ArtistAlbumsHolder));
                    client.DefaultRequestHeaders.Add("Authorization", spotifyKey);
                    var streamTask = await client.GetStreamAsync(apilink);

                    HttpResponseMessage response = await client.GetAsync(apilink);

                    ArtistAlbumsHolder holder = null;
                    holder = serializer.ReadObject(streamTask) as ArtistAlbumsHolder;
                    return(holder);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    return(null);
                }
            }
        }
Exemple #2
0
        public ArtistAlbumsHolder Get(string id, string offset = "0", string limit = "20")
        {
            RequestSpotify     rs     = new RequestSpotify();
            ArtistAlbumsHolder holder = new ArtistAlbumsHolder();

            holder = rs.GetArtistAlbums(id, offset, limit).Result;
            return(holder);
        }