I'm using the Google Analytics Admin API to create properties. My loop goes along, creating properties and custom dimensions, between 3 and 20 properties, then throws an error:
Exception creating property for 305890164: {
"message": "The caller does not have permission",
"code": 7,
"status": "PERMISSION_DENIED",
"details": []
}
This is thrown when I'm creating a new custom_dimension for a property I just created. I don't understand why some random number of properties/dimensions are created before it throws the error. Any thoughts?
Also - nice that some of the code is out of Alpha into Beta.. but it's taking a loooooooooong time.
My guess is that you are creating the custom dimensions too fast after the property is created. PERMISSION_DENIED
is thrown when you don't have access to the property or if the property doesn't exist.
I'm guessing that the property creation hasn't propagated enough for your create custom dimension call.
I would try adding retry logic to your code and maybe with exponential back-off. I admit that it is weird to retry a PERMISSION_DENIED
error, however I don't believe that the API will throw a NOT_FOUND
error in this case.