Can't create provisioning profile using app store connect api.

Hello, I've been trying to automate my app distribution process and creating the backend of my service as per the documentation https://developer.apple.com/documentation/appstoreconnectapi/

But while creating a new provisioning profile, I see

{'errors': [{'status': '500', 'code': 'UNEXPECTED_ERROR', 'title': 'An unexpected error occurred.', 'detail': 'An unexpected error occurred on the server side. If this issue continues, contact us at https://developer.apple.com/contact/.'}]}

my post request function looks like this

def createProvisioningProfile(self, name, bundle_rel_id, certificate_rel_id):
        url = self.api_home + "profiles"
        body = {
            "data": {
                "attributes": {
                    "name": name,
                    "profileType": "IOS_APP_STORE"
                },
                "relationships": {
                    "bundleId": {
                        "data": {
                            "type": "bundleIds",
                            "id": bundle_rel_id
                        }
                    },
                    "certificates": {
                        "data": {
                            "type": "certificates",
                            "id": certificate_rel_id
                        }
                    }
                },
                "type": "profiles"
            }
        }
        response = requests.post(url, headers=self.headers, json=body)
        return response.json()

Language : Python3

Every other endpoint works perfectly (create bundleid, addcapabilities etc.) could someone please help me with this?

Answered by iamam305 in 723525022

ok so I found what was wrong, posting it here just incase someone also happens to stumble upon this... the certificates data must be an array... as in

"certificates": {
    "data": {
        "type": "certificates",
        "id": certificate_rel_id
    }
}

must be changed to

"certificates": {
    "data": [{ // Added [] 
        "type": "certificates",
        "id": certificate_rel_id
    }]
}

im not sure how to close this thread or something so im just gonna leave it like this

Accepted Answer

ok so I found what was wrong, posting it here just incase someone also happens to stumble upon this... the certificates data must be an array... as in

"certificates": {
    "data": {
        "type": "certificates",
        "id": certificate_rel_id
    }
}

must be changed to

"certificates": {
    "data": [{ // Added [] 
        "type": "certificates",
        "id": certificate_rel_id
    }]
}

im not sure how to close this thread or something so im just gonna leave it like this

Can't create provisioning profile using app store connect api.
 
 
Q