CommunityToolkit / MVVM-Samples

Sample repo for MVVM package
Other
1.11k stars 222 forks source link

RedditService service fails with 403 Blocked error #122

Open gragra33 opened 1 year ago

gragra33 commented 1 year ago

There is an easy fix for this, we need to add a 'User-Agent' header, something like below:

public interface IRedditService
{
    /// <summary>
    /// Get a list of posts from a given subreddit
    /// </summary>
    /// <param name="subreddit">The subreddit name.</param>
    [Headers("User-Agent: Awesome CommunityToolkit.Mvvm Sample App")]
    [Get("/r/{subreddit}/.json")]
    Task<PostsQueryResponse> GetSubredditPostsAsync(string subreddit);
}

Now the sample in the 'The Final Result!' will work correctly.