1

I'm working with my new app for Windows phone and using Nokia music api which is now Nokia mix radio api. There are many changes in it and MusicClientAsync is no longer functional.

I want to get list of top artist in user region. I'm trying to use following code but it is showing an error and I'm not able to find any documentation.

private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        MusicClient client = new MusicClient(MyAppId);
        ListResponse{<MusicItem>} result = await client.GetTopArtistsAsync();
    }
Grice
  • 1,345
  • 11
  • 24
  • What kind of error is showing to you? can you edit your question, including the current error message/exception you are getting? – Josue Yeray Feb 12 '14 at 14:15
  • The 'await' operator can only be used within an async method. Consider making this method with 'async' modifier anf changing its return type to 'Task'. – user3235267 Feb 12 '14 at 14:33
  • I tried copy some examples from nokia developer api reference but they too showing same error. Can u update me with new method to get this list of artist? – user3235267 Feb 12 '14 at 14:35
  • The problem is, the method you are using to call GetTopArtistsAsync is not an async method. Can you paste your code in the question please? – Josue Yeray Feb 12 '14 at 14:37
  • Here is code from nokia api reference documentation and it showing error too. MusicClient client = new MusicClient(MyAppId); ListResponse result = await client.SearchAsync("muse"); – user3235267 Feb 12 '14 at 14:45
  • Sir i m very new to developer field and i m trying to learn to make windows app. Please suggest me any other method to get list of top artist using nokia music api. – user3235267 Feb 12 '14 at 14:48

1 Answers1

1

What you need to do, is to add the async keyworkd to your Button_Click method:

private async void Button_Click_1(object sender, RoutedEventArgs e) 
{
    MusicClient client = new MusicClient(MyAppId);
    ListResponse{<MusicItem>} result = await client.GetTopArtistsAsync();
}

See how i add async word after private and before void this way your Button_Click_1 method can use the await keyword. THis way the call to GetTopArtistsAsync is going to work.

Josue Yeray
  • 1,163
  • 1
  • 11
  • 12