首页 > 解决方案 > C# 中的 Google.Apis.Urlshortener 给出错误 JsonReaderException

问题描述

我想使用 Google Nuget 包来缩短 URL。我包括了所有必需的文件

 public string shortenIt(string url)
    {       
        UrlshortenerService service = new UrlshortenerService(new BaseClientService.Initializer()
        {
            ApiKey = "*************************",
            ApplicationName = "***************",
        });
        Url response = service.Url.Insert(new Url { LongUrl = url }).Execute();
        return response.Id;
    }

我收到以下错误

  Url response = service.Url.Insert(new Url { LongUrl = url }).Execute();

错误

  JsonReaderException: Error parsing NaN value. Path '', line 1, position 1 

我很想知道解决方案..谢谢

标签: c#google-apinugeturl-shortenerjsonreader

解决方案


Google 的 URL 缩短器不再可用,您应该转而使用 Google 的 Firebase 动态链接。

来源:https ://developers.googleblog.com/2018/03/transitioning-google-url-shortener.html


推荐阅读