Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I'm trying to do an app that gets information from an IP but I can't continue because I got this error in "SearchArtist"

These are the two parts of the code that I am having issues

public static SpotifyResult SearchArtist(string searchWord)
      {
          var client = new RestClient("https://api.spotify.com/v1/search");
          client.AddDefaultHeader("Authorization", $"Bearer {token.access_token}");
          var request = new RestRequest($"?q={searchWord}&type=artist", Method.GET);
          var response = client.Execute(request);

          if (response.IsSuccessful)
          {
              var result = JsonConvert.DeserializeObject<SpotifyResult>(response.Content);
              return result;
          }
          else
          {
              return null;
          }

      }


and this one

public class SpotifyResult
      {
          public Artists artists { get; set; }
      }


What I have tried:

I make everything public already and I am still getting the message error
Posted
Updated 11-Mar-22 0:19am
Comments
Richard MacCutchan 11-Mar-22 7:18am    
Which line cause the error?

1 solution

If you don't understand an error message, google it: cs0050 - Google Search[^]
Th top hit takes to to the MS documentation for the error: Compiler Error CS0050 | Microsoft Docs[^]

Which says that the problem is due to !"inconsistent access" : you are trying to return or pass a value to a public method but the type is more restrictive.
It may be that the Artists class is private, internal, protected, or protected internal which would mean that although an external class could access the method, it can't access the return value of the property, so you get an error CS0050.

Start by using VS to replace your var values with explicit types: that way it's a lot easier to see exactly what classes you are dealing with, then trace them to find out the accessibility level.

Sorry, but we can't do any of that for you!
 
Share this answer
 
Comments
Dave Kreskowiak 11-Mar-22 8:56am    
It's possible the Artists type used by the SpotifyResult is private.
OriginalGriff 11-Mar-22 9:54am    
It's possible - but without access to his code ...
Dave Kreskowiak 11-Mar-22 10:44am    
Or any idea which line is throwing, combined with this might not ever be the code that is throwing...
OriginalGriff 11-Mar-22 11:24am    
Good here, ain't it? :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900