0

I can see the JSON response but I'm not able to deserialize the ExternalIDs in google apps directory API. (C#)

var users = service.Users.Get(EMail).Execute();
var externalIDs = JsonConvert.DeserializeObject<UserExternalId>(users.ExternalIds);

Gives a compiler error:

Error 1 The best overloaded method match for 'Newtonsoft.Json.JsonConvert.DeserializeObject(string, params Newtonsoft.Json.JsonConverter[])' has some invalid arguments

Zonus
  • 2,313
  • 2
  • 26
  • 48
  • What is the content of users.EternalIds? – peleyal Feb 02 '15 at 16:14
  • It's a JSON array of Google.Apis.Admin.Directory.directory_v1.Data.UserExternalId – Zonus Feb 02 '15 at 16:19
  • I was able to get it to work by using dynamic but I'd like to strong type the class. It appears that the class variables may not have the same case as the XML... eg. CustomType vs customType – Zonus Feb 02 '15 at 16:20

1 Answers1

1

I believe the reason is an error in your code. As you commented the object ExternalIds contains a json array. Thus your code should be:

UserExternalId[] exId = Newtonsoft.Json.JsonConvert.DeserializeObject<UserExternalId[]>(x.ExternalIds.ToString());

Notice the [] on the objecttype to deserialize.

zu1b
  • 422
  • 5
  • 11