0

I have a very simple program meant to use the Google Discovery API. However, when I try to use the getRest call, it fails as below. Any ideas? I'm using the most recent version of the Discovery API from NuGet, VS 2012 Pro.

DiscoveryService service = new DiscoveryService(new Google.Apis.Services.BaseClientService.Initializer());

//this works no problem
service.Apis.List().Execute();

//this works on the API reference page's Try It! area, but fails here
service.Apis.GetRest("admin", "directory_v1").Execute();

This is the resulting error that is thrown in the Google.Apis.Requests.ClientServiceRequest class, on the Execute() method - line 96:

JsonSerializationException was unhandled

Additional content found in JSON reference object. A JSON reference object should only have a $ref property. Path 'schemas.User.properties.name.description', line 1251, position 20.

Community
  • 1
  • 1
squid808
  • 1,430
  • 2
  • 14
  • 31

1 Answers1

1

This is a documented error. Get the generated discovery to discovery its own discovery document #79

The only work around I have currently found is to use the Client lib to log in and then manually make my requests from the Discovery API. Its messy and doesn't work very well because you can use the class structure that the Discovery API class library would have given you.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Sorry, I didn't realize I never accepted this. Please have my upvote and an apology. :) – squid808 Mar 29 '16 at 15:06
  • If I remember I can post how to compile the source manually and fix it – Linda Lawton - DaImTo Mar 29 '16 at 16:35
  • No worries, I actually ended up just [making my own custom deserializer that just changes '$ref' to 'ref' and ignores it, since I don't need to resolve the references](https://github.com/squid808/gShell/blob/4a7d6bade4e6842faf3b3fc63ea33426bef64ad9/gShell/gShell/dotNet/Utilities/CustomSerializer/CustomSerializer.cs#L158-L163). Thank you as always! – squid808 Mar 29 '16 at 17:33