1

I am using InstaSharp to try and get a user's latest media posts. I am getting error:

{"Exception has been thrown by the target of an invocation."}

Here is my code:

    public async Task<string> GetUserRecentMedia(string userId)
    {
        string response = string.Empty;
        try
        {
            InstagramConfig config = new InstagramConfig(ClientId, ClientSecret, RedirectUri, string.Empty);
            Users usersEndpoints = new Users(config);
            response = ConvertToJson(usersEndpoints.Recent(userId));
        }
        catch (Exception ex) { }
        return response;
    }
Kiquenet
  • 14,494
  • 35
  • 148
  • 243
ibexy
  • 609
  • 3
  • 16
  • 34

1 Answers1

0

you need to call InstaSharp methods in async methods (as you have done) And await the method you want to call so

await usersEndpoints.Recent(userId);
Vikas Pal
  • 83
  • 1
  • 1
  • 10
Ramin
  • 87
  • 2
  • 7