How to Modify User Account by Appstoreconnect API

I can’t understand how to create the http body of the Modify User Account api:

PATCH https://api.appstoreconnect.apple.com/v1/users/{id}


In particular the array:


[UserUpdateRequest.Data.Relationships.VisibleApps.Data]


What are the required id and type properties of Data object?

Could somebody provide a code or postman example of a request ?


This is the url of the API:


https://developer.apple.com/documentation/appstoreconnectapi/modify_a_user_account

Thanks, this is exactly the library I'm using in my project, but I get this error: so I was trying to understand how to shape the visibleApp value.


Request failed with status code 409 and response {

"errors" : [ {

"id" : "96762428-38c5-45c5-a700-fadd798fe012",

"status" : "409",

"code" : "ENTITY_ERROR.RELATIONSHIP.INVALID",

"title" : "The provided entity includes a relationship with an invalid value",

"detail" : "The relationship 'visibleApps' expects data as an array but an object was given.",

"source" : {

"pointer" : "/data/relationships/visibleApps"

}

} ]

}).

I've undestood which is the App Id: it's the one in the AppstoreConnect app description.

Hi Giurobrossi!

In your POST/PATCH request, the value of relationships.visibleApps.data must be an array because you can assign more than one app to the user. The full payload should look like this:

Code Block
PATCH /v1/users/***
{
"data": {
"type": "users",
"id": "***",
"relationships": {
"visibleApps": {
"data": [
{"type": "apps", "id": "..."},
{"type": "apps", "id": "..."}
]
}
}
}
}


Where ... is the ID of the app (the same ID you get back from the API when you do a GET /v1/apps and that shows as the "Apple ID" in App Store Connect on the web).

Bear in mind this will replace the set of visible apps for this user. In other words, the above request will grant the user just those two apps, and remove their access to any other apps. If you just want to add visible apps to the existing set for the user, use this instead:

Code Block
POST /v1/users/***/relationships/visibleApps
{
"data": [
{"type": "apps", "id": "..."},
{"type": "apps", "id": "..."}
]
}

How to Modify User Account by Appstoreconnect API
 
 
Q