Search code examples
c#google-apinugeturl-shortenerjsonreader

Google.Apis.Urlshortener in C# giving Error JsonReaderException


I want to use Google Nuget package for shortening URLs. I included all the required files

 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;
    }

I am getting the following error on

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

Error:

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

I would be please to know the solution..Thanks


Solution

  • Google's URL shortener is no longer available, you should move to using Google's Firebase Dynamic Links.

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