0
votes

I know that it's supposed to go in the request body, but how does it fit in with the rest of the metadata? What's the NAME part of the name/value pair for the actual swagger text? I'm trying to import a swagger documentation into Azure API Management by passing in a string representation of the swagger doc. According to the documentation below, the "Content-Type" should be set to "application/vnd.swagger.doc+json" and the "import" query parameter should be set to "true". However, there is nothing in the documentation that specifies where this "import" parameter should go. Here is the PUT example that Microsoft provides:

PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}?api-version=2016-10-10

Is there an example that shows how to pass in the swagger string along with all the other required parameters in the body?:

Apis documentation

1
Well, since it says "import" query parameter, the parameter goes to the query string: https://....?import=true.Helen
I tried using this url: devimsapim.management.azure-api.net/apis/… ersion=2016-10-10&import=trueTheDude
But I still get the following error: Invoke-RestMethod : {"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"path","message":"'path' must not be empty."}]}}TheDude
After a lot of trial & error, I was FINALLY able to create a bare bones API with the following in the request body. However, I need to figure out what the NAME part of the name/value pair is supposed to be used for the actual swagger text. The Microsoft documentation is not clear:TheDude
$body = @{ name = "Bentley.STS.RegistrationService" path = "imsregistration" serviceUrl = "baseadress.com/registrationservice" protocols = @("https") }TheDude

1 Answers

2
votes

To import swagger file you need to make a PUT call at

https://.../apis/{desired-api-id}?path={desired-api-path-suffix}&import=true&api-version=...

Swagger content should go as is into request body, without any encoding. Various pieces of information from swagger will be used to fill in the API details, it's only path that has to be explicitly passed in query as it just can't be found there.