reactiveui / refit

The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
https://reactiveui.github.io/refit/
MIT License
8.47k stars 745 forks source link

Bug? #354

Closed RahmanM closed 7 years ago

RahmanM commented 7 years ago

Hi,

Created a new C# console application with .net 4.61, added nuget package for refit and copy and pasted the sample code from the repo. But I get this error " HResult=0x80131509 Message=IGitHubApi doesn't look like a Refit interface. Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project. Source=Refit"

packages: <?xml version="1.0" encoding="utf-8"?>

Code:



  static async Task RetrofitTest1()
        {
            var gitHubApi = RestService.For<IGitHubApi>("https://api.github.com");

            var octocat = await gitHubApi.GetUser("octocat");

            Console.ReadLine();
        }

    public interface IGitHubApi
    {
        [Get("/users/{user}")]
        Task<User> GetUser(string user);
    }

    public class User
    {
        public string login { get; set; }
        public int id { get; set; }
        public string avatar_url { get; set; }
        public string gravatar_id { get; set; }
        public string url { get; set; }
        public string html_url { get; set; }
        public string followers_url { get; set; }
        public string following_url { get; set; }
        public string gists_url { get; set; }
        public string starred_url { get; set; }
        public string subscriptions_url { get; set; }
        public string organizations_url { get; set; }
        public string repos_url { get; set; }
        public string events_url { get; set; }
        public string received_events_url { get; set; }
        public string type { get; set; }
        public bool site_admin { get; set; }
        public string name { get; set; }
        public string company { get; set; }
        public string blog { get; set; }
        public string location { get; set; }
        public object email { get; set; }
        public object hireable { get; set; }
        public object bio { get; set; }
        public int public_repos { get; set; }
        public int public_gists { get; set; }
        public int followers { get; set; }
        public int following { get; set; }
        public DateTime created_at { get; set; }
        public DateTime updated_at { get; set; }
    }
clairernovotny commented 7 years ago

Do you have a more complete repro? Refit depends on build-time tooling, so snippets aren't usually enough to diagnose.

RahmanM commented 7 years ago

Hi, I don't get that error anymore. I replaced the Github to one of my own APIs and it worked like charm. I actually have problems connecting to Github right now - 3:47 PM sydney time.