0

I'm working with Google Directory API (admin sdk) through python and some user updates seem to be doing less than expected. I want to update addresses/emails/...-fields, overwriting the list with an empty one.

I tested in Try it! and even that doesn't work: enter image description here

The result is 200 OK and everything seem to work until a get-request reviles that nothing has happened.

Niklas Ternvall
  • 510
  • 1
  • 3
  • 19

1 Answers1

1

I just tried to reproduce this and i was able to remove addresses after a few failed attempts.

This is what had to be done in "Try it!"

Switch to the "Freeform Editor". There's a dropdown in the box for the request body.

As request body send

{
  "addresses": [{}]
}

Why doesn't it work for you? Since you use the structured editor your request is enclose in double quotes ("") thus the adress is a big mess and nothing happens except you get a really messed up response from the update endpoint. Why in the world google would return a status code 200 (OK) for that evades me.

If you transfer this learning to your code it should work. Sorry i don't grok python so i can't help with the python code.

konqi
  • 5,137
  • 3
  • 34
  • 52
  • I guess "addresses": [ { "type": "custom", "customType": "" } ] is as close to an empty list as it goes. Thanks! – Niklas Ternvall Aug 26 '15 at 12:52
  • I will just add that it would seem as there's no general rule to this. I hope there is an equivalent for empty lists, for each structure. :-/ – Niklas Ternvall Aug 26 '15 at 13:06
  • hm if the python lib is anywhere near the same as the java lib you could set the type and customType after instantiating an Address object to null. In fact it should be possible to set a generic JsonObject instead. That or you can use a generic ApiClient and do the post by hand. I aggree that this is inconvenient. At least it's working and you can always contact google support about it. If this occurs in more than one place you could define some static empty objects and reuse them. – konqi Aug 26 '15 at 13:11
  • I no longer see this as an language issue, as "Try me!" fails to preform. I also feel obligated to point out emails is an even harder nut to crack as it has dependencies to primaryEmail. – Niklas Ternvall Aug 26 '15 at 13:25
  • You should not remove the primary email address because that is the Google Apps identifier. You should be able to update the primary email address though. – konqi Aug 26 '15 at 13:28