Business Central Automation API Rapidstart package upload and import

I’m currently setting up company by automation API by following the setups at Introduction to automation APIs - Business Central | Microsoft Docs. I have created a company in Business Central but need to create 5 similar copies with same data like items, customers, COA, etc using API. I exported a configuration package from the base company but having trouble when I upload the package using API and try to import it. I’m currently using postman to test things out.

pastedimage1615912328195v1.png

I have added the .rapidstart file as form data with content type application/octet-stream. Using “PATCH api.businesscentral.dynamics.com/v2.0/{environment name}/api/microsoft/automation/v2.0/companies({companyId})/configurationPackages({packageId})/file(’{packageName}’)/content” , it gives the expected response “204 No Content”.

When I import using "POST api.businesscentral.dynamics.com/v2.0/{environment name}/api/microsoft/automation/v2.0/companies({companyId})/configurationPackages({packageId})/Microsoft.NAV.apply ", it returns “200 OK”.

It returns an error while applying the package using “POST api.businesscentral.dynamics.com/v2.0/{environment****name}/api/microsoft/automation/v2.0/companies({companyId})/configurationPackages({packageId})/Microsoft.NAV.apply” .

{
“error”: {
“code”: “Application_DialogException”,
“message”: “Import Status is not completed. You must import the package before you apply it. CorrelationId: a8ade702-ecaf-4ae4-a1f2-ebc5495c9a21.”
}
}

It gives me the same ID if I do a GET of recently imported package and I did use the If-Match header * for PATCH request. Following is the result when I did "GET api.businesscentral.dynamics.com/.../{environment name}/api/microsoft/automation/v2.0/companies({companyId})/configurationPackages":

pastedimage1615912408753v2.png

My guess is the .rapidstart package is not being uploaded in the process.

Not sure what is causing the error. I tried giving it extra minutes after upload and import requests to facilitate any backend processing. Any help is appreciated.