400 Bad Request
"domain": "global","reason": "required","message": "Field permissions is required."}],"code": 400,"message": "Field permissions is required."}}Posting the request as wellPOST https://www.googleapis.com/analytics/v3/management/accounts/41011686/entityUserLinks?fields=permissions%2CuserRef&key={YOUR_API_KEY} Content-Type: application/json Authorization: Bearer ya29.1.AADtN_U_rzDq7M5Xo4p31vskkFbed2SOlFyLFg6_N7xgb_MBD9IKfGJl8E5Y-Qe67_JJOnp1 X-JavaScript-User-Agent: Google APIs Explorer
| NetBooster Affiliate is a subsidiary of NetBooster Holding A/S and NetBooster SA. This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please contact us. The content of this email does not necessarily reflect the views or opinions of NetBooster Affiliate. |
{
"permissions": {
"local": [ "READ_AND_ANALYZE" ]
},
"userRef": {
"id": "_",
"email": "_",
"kind": "analytics#userRef"
}
}
In other words, the "permissions" section needs to be surrounded by {curly brackets}. The same applies to the userRef section, and it applies even if you only have one items within that. I don't know the software you are using to generate the JSON code, but it might be an idea to use the "Try It!" section towards the bottom of the help page https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/webpropertyUserLinks/insert to get a JSON body that definitely works. Then see if you can submit that as a post request*, then lastly see if you can get your software to build the full thing, creating the correct JSON body and submitting it through POST.
Please note that I am quite new to this myself, so I don't know if you're also supposed to include the "entity" section. But if you get it working on the Try It! section, then that will tell you that you have enough information in the JSON body.
*if you try to insert permissions for a user who has already been added, you will receive a 400 error "The user is already on the enitty"[sic]; if so you should try a different user or manually remove their permissions first.
If you do get it working, please post your (redacted) JSON body here, so others can benefit from your experience :)
Alun