How to update app description using App Store Connect API?

I've been able to create a new version, but I am unable to update the description. There are no examples for that, so I am going through trial&error (mostly error...).

I am posting to:

https://api.appstoreconnect.apple.com/v1/appStoreVersionLocalizations

the following data:

Code Block
"data": {
"type": "appStoreVersionLocalizations",
"attributes": {
"locale": "it",
"description": newAppDescription
},
"relationships": {
"appStoreVersion": {
"data": {"type": "appStoreVersions", "id": versionId
}
}
}
}

where newAppDescription is obviously a string and versionId is obtained from:

https://api.appstoreconnect.apple.com/v1/apps/[MyAppAppleID]/appStoreVersions

filtering by appStoreState=PREPARE_FOR_SUBMISSION.

I get this error:

Code Block
    "errors": [
        {
            "id": "347ed3fe-0f11-41e1-a70b-7c66b949cff4",
            "status": "409",
            "code": "ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE",
            "title": "The provided entity includes an attribute with a value that has already been used",
            "detail": "Entity with locale: it already exists. Try updating.",
            "source": {
                "pointer": "/data/attributes/locale"
            }
        }
    ]


I've tried replacing the request.post with request.patch, but then I get a "405-Method not allowed".

Do you have any hints? Thank you
Solved! I was incorrectly POSTing but POST is for creating new instances. I should have used PATCH but was not correctly navigating the hierarchy.

Here is the working code. I put it here because I have not found anything about this on the web, so it could be useful. Please note, I have only one localization so I expect just one match in the second "get" and I don't bother filtering the results by locale). Also this will run after creating the new version so there should already be a version in the PREPARE_FOR_SUBMISSION state.

Code Block
BASE_URL = 'https://api.appstoreconnect.apple.com/v1/'
URL = BASE_URL + 'apps/' + ID_APP + '/appStoreVersions'
p = {"filter[appStoreState]": "PREPARE_FOR_SUBMISSION"}
r = requests.get(URL, params=p, headers=HEAD)
versionId = r.json()['data'][0]['id']
URL = BASE_URL + 'appStoreVersions/' + versionId + '/appStoreVersionLocalizations'
r = requests.get(URL, headers=HEAD)
localizationId = r.json()['data'][0]['id']
URL = BASE_URL + "appStoreVersionLocalizations/" + localizationId
data = {
"data": {
"id": localizationId,
"type": "appStoreVersionLocalizations",
"attributes": {
"description": "here goes your app description..."
}
}
}
r = requests.patch(URL, json=data, headers=HEAD)


How to update app description using App Store Connect API?
 
 
Q