When trying to publish an API using the PAPI, it shows an error due to there is no policyEntity. There's no problem creating and publishing an API manually. None of these Curl commands seem to work:
curl -X PUT -H "Authorization: Bearer <TOKEN>" -d '{"policyEntities":"["policyEntityUuid":"172594b6-18ba-4b0c-8d61-807db457e81d","policyTemplateArguments":[]]"}' "https://<PORTAL_TENANT_ID>:9443/<TENANT_ID>/api-management/1.0/apis/<API_UUID>/publish" -k
curl -X PUT -H "Authorization: Bearer <TOKEN>" -d '{"[{\"policyEntityUuid\":\"172594b6-18ba-4b0c-8d61-807db457e81d\",\"policyTemplateArguments\":[]}]"}' "https://<PORTAL_TENANT_ID>:9443/<TENANT_ID>/api-management/1.0/apis/<API_UUID>/publish" -k
curl -X PUT -H "Authorization: Bearer <TOKEN>" -d '{"policyEntityUuid":"172594b6-18ba-4b0c-8d61-807db457e81d","policyTemplateArguments":[]}' "https://<PORTAL_TENANT_ID>:9443/<TENANT_ID>/api-management/1.0/apis/<API_UUID>/publish" -k
API Portal: 4.5
When you create an API, even if you create it with a policyEntity, the field gets ignored by the POST command.
After you create the API, you need to add the policyEntity using a PUT command that looks something like this:
curl -X PUT -H "Authorization:Bearer <TOKEN>" --header "Content-Type:application/json" -d '[{"policyEntityUuid": "<POLICY_ENTITY_UUID>", "policyTemplateArguments": [ ]}]' "https://<PORTAL_TENANT_ID>:9443/<TENANT_ID>/api-management/1.0/apis/<APIUUID>/policy-entities" -k
NOTE: When this command is executed successfully, it will not return a response.
As an option, you can confirm the policy entity has been added to the API:
curl -X GET -H "Authorization:Bearer <TOKEN>" "https://<PORTAL_TENANT_ID>:9443/<TENANT_ID>/api-management/1.0/apis/<API_UUID>/policy-entities" -k
Then you can publish the API:
curl -X PUT -H "Authorization:Bearer <TOKEN>" "https://<PORTAL_TENANT_ID>:9443/<TENANT_ID>/api-management/1.0/apis/<API_UUID>/publish" -k
NOTE: When this command is executed successfully, it will not return a response. But you should see the API published within the Portal dashboard.
NONE | 172594b6-18ba-4b0c-8d61-807db457e81d |
APIKEY | 72093738-871a-45bd-b114-ad3a61893ac0 |
OAUTH 2.0 | 2e69dcfb-2302-4959-b43c-1931a152b8e4 |