Generate Swagger from Postman Collection

Iโ€™m trying to generate a swagger json from a collection but everytime i try to โ€œsendโ€ the following URL: https://api.getpostman.com/collections/:collection_id , i have alway this response :

{
    "error": {
        "name": "forbiddenError",
        "message": "You are not permitted to perform the action."
    }
}

Someone know why ? i mean i have the collection id from a collection in my space , is a problem of visibility ?

You need to include an API key when targeting the collections endpoint.

There are a couple of methods for doing this that are covered in day 4 (Authorization) in the 15 days of postman training.

https://www.postman.com/postman/workspace/15-days-of-postman-for-testers/

Hi @michaelderekjones ,

with API key you mean to add the X-API-Key ?
i followed this guide Postman where i genereta the value for the API key X-API-Key

or you mean something else ?

Thanks

Yes, the X-API-Key.

All that example does is get retrieve a collection and then has some post-response code that creates a visualization that you can copy and paste. (It uses sendRequest to hit another API for the conversion).

If you are getting a forbidden error, its because of the authorization on the request. What status code are you getting? A 401?

You just need an environment variables called postman_api_key with the current value set accordingly.

Hi @michaelderekjones , thank for your patience i had very busy days.
By the way i tried to set the X-API-Key in the collection like you suggest and i set also the value of {{postman_api_key}} in the Variables tab

then i create a GET request inside the collection in the pic with the API Key e the id of the collection that i want the swagger in output but i receive the same response like the foloowing pic:

this is the structure on postman, is correct ?

image

What does your API key variable look like?

It should start with PMAK-.

You might want to try generating a new API key and see if that resolves your issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.