Google.Apis.Urlshortener in C# giving Error JsonReaderException

347 Views Asked by At

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

1

There are 1 best solutions below

3
On BEST ANSWER

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