Postman: Create a collection for an API via Postman's public API - postman

I am able to create a collection with the postman public API using the following endpoint:
POST https://api.getpostman.com/collections
In the Postman UI, there is the possibility to create a new collection for an API:
How can I do the same thing via Postman API?
I would imagine that there is supposed to be an endpoint like
POST https://api.getpostman.com/api/{{apiId}}/collections

Related

How do I invoke a postman-defined request within a postman pre-request script?

All examples I've seen of calling a REST API within a Pre-Request script use the http API pm.sendRequest().
I'd much rather 'submit' a request that is defined through the Postman UI. Then, the request details can easily be managed through the Postman UI and shared across multiple Pre-Request scripts.
Is there a Postman API to send/invoke a specific request item in a collection?
What you're looking for is postman.setNextRequest()
You can check the documentation here: Building request workflows

Auth to google API with API-Key instead of OAuth 2.0

in https://developers.google.com/calendar/api/v3/reference/calendarList/list?apix=true#auth
I can see, that I can use OAuth2 and API-Key to authenticate for the calendarList endpoints
My first test with postman and OAuth2 works perfect: I get the JSON List of all calendars of the autheticated user
Now I test the entpoint with authentication over API-Key
I create the API-Key and enabled the calendar for this api key:
Problem:
I've tested it with postman and Auth-Type=ApiKey and with Parameter key=MYAPIKEY but always get error 401 "Request is missing required authentication credential"
Does anyone have a (postman) example to access the google calendard api with an API-Key?
API keys are only used to access public data not private user data.
In order to use an api key with postman you would simply take the rquest and add key=YourKEY on the end
The following is a good example of this but unfortunately there is currently an issue with API keys and public calendars. Requiring authorization instead of just an api key194427607
https://www.googleapis.com/calendar/v3/calendars/en.danish%23holiday%40group.v.calendar.google.com?key=[YOUR_API_KEY]
You are not going to be able to use calendar list without being authorized calendarlist.list states in the documentation that you must be authorized as its private user data.

Get user API key automatically while endpoint returns HTTP 401

Is there a way in Postman to obtain automatically, if an endpoint returns an HTTP 401, a new API key for that user by calling the login endpoint? In this situation Postman loads the result and store the API key in a variable in the specific Environment.
The test tab in Postman allows you to write some JS code that retrieves the response data and allows you to act accordingly.
Then the postman API allows you to set the next request in the collection runner or newman, so you can just call the login request properly.
Basically something like this:
const jsonData = pm.response.json()
if (pm.response.code === 401) {
pm.setNextRequest('login')
}
Here is some further reading about scripting in postman.

How to save a response as example with Postman API

I'm using postman MockServer feature.
I have 2 collections in Postman. One for my real server, and the other for the mock.
Postman MockServer need examples to mock a response when you make a request call.
I need to automate the creation of new examples. I think about Postman API or Newman to do so.
But I can't find anything in the documentation about saving new examples.
Any idea ?

In AWS how do I add an API key to my API?

Hello: I've been following two tutorials in the AWS documentation:
creating the sample pet store API (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-from-example.html)
...and creating an API key (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html#api-gateway-usage-plan-create-apikey).
When I test the pet store get method with the provided URL, it returns:
Welcome to your Pet Store API You have successfully deployed your
first API. You are seeing this HTML page because the GET method to the
root resource of your API returns this content as a Mock integration.
The Pet Store API contains the /pets and /pets/{petId} resources. By
making a GET request to /pets you can retrieve a list of Pets in your
API. If you are looking for a specific pet, for example the pet with
ID 1, you can make a GET request to /pets/1.
You can use a REST client such as Postman to test the POST methods in
your API to create a new pet. Use the sample body below to send the
POST request:
{
"type" : "cat",
"price" : 123.11 }
Now I go to the API Gateway -> API -> Resources -> -> Method Request -> API Key Required and change it to "True" and redeploy.
When I go to the provided URL to test, now the page returns:
{"message":"Forbidden"}
Which makes sense... I told it API required = true, right?
So my question is, how do I pass the API key? So that I don't get the "forbidden" result? I didn't see that in the tutorial links I pasted above and haven't been able to find elsewhere.
You Create a Usage Plans
Attach this usage plan to your API and Stage
Create an API Key
Now invoke your API with header named x-api-key and value of it is the API Key created in step-3
Sample:
curl -i -H "x-api-key: Cd2YiWs8Fv8Lg6njI0wXf1iiNOE94XjM3EQe8567" -X GET https://7r9cvghbf4.execute-api.ap-northeast-2.amazonaws.com/dd/pets
Assuming you've followed all steps for creating the API key you can use this API key by specifying it in the x-api-key header within your request.
You distribute API keys to your customers and require them to pass the API key as the X-API-Key header of each incoming request.
More information for using API keys in API Gateway is available on: Choose an API key source - Amazon API Gateway