简体   繁体   English

找不到Simple.Odata.Client资源

[英]Simple.Odata.Client resource not found

I am following a tutorial from Github that seems to error when I call the 'await client' line below. 我正在遵循Github的教程,当我在下面调用“ await client”这一行时,似乎出错了。 The error is Simple.OData.Client.WebRequestException: 'Resource Not Found' however the url works fine when I visit it in a browser. 错误是Simple.OData.Client.WebRequestException: 'Resource Not Found'但是当我在浏览器中访问该URL时,它可以正常工作。 Any idea how to troubleshoot this further? 知道如何进一步解决此问题吗?

Main.cs: Main.cs:

using Simple.OData.Client; //Install-Package Simple.OData.Client

static void Main(string[] args)
{
    MCdemo().GetAwaiter().GetResult();
    Console.WriteLine("Press any key to exit");
    Console.ReadKey();
}

public static async Task<string> MCdemo()  
{
    var client = new ODataClient("https://packages.nuget.org/v1/FeedService.svc/");

    var x = ODataDynamic.Expression;
    IEnumerable<dynamic> packages = await client
        .For(x.Packages)
        .Filter(x.Title == "Simple.OData.Client")
        .FindEntriesAsync();

    foreach (var package in packages)
    {
        Console.WriteLine(package.Title);
    }

    return "success";
}

You are getting that exception because that is an old URL to Nuget packages.The tutorial should have been updated. 您之所以会收到该异常,是因为那是Nuget软件包的旧网址。本教程应该已经更新。 The new Nuget url is https://api.nuget.org/v3/index.json , see this SO and Github 新的Nuget网址为https://api.nuget.org/v3/index.json ,请参阅此SOGithub

But for your tutorial you can use this http://services.odata.org/V4/TripPinServiceRW/ 但是对于您的教程,您可以使用此http://services.odata.org/V4/TripPinServiceRW/

var client = new ODataClient("http://services.odata.org/V4/TripPinServiceRW/");

var x = ODataDynamic.Expression;
IEnumerable<dynamic> values = await client
    .For(x.Photos)
    .FindEntriesAsync();

    foreach (var photo in values)
    {
      Console.WriteLine(photo.Name);
    }

return "success";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM