• 沒有找到結果。

Set up Postman

在文檔中 Amazon Pinpoint (頁 13-19)

Step 1.2: Create an IAM user

After you create the policy, you can create an IAM user and attach the policy to it. When you create the user, IAM provides you with a set of credentials that you can use to allow Postman to execute Amazon Pinpoint API operations.

To create the user

1. Open the IAM console at https://console.aws.amazon.com/iam/.

2. On the IAM console, in the navigation pane, choose Users, and then choose Add user.

3. Under Set user details, for User name, enter a name that identifies the user account, such as PostmanUser.

4. Under Select AWS access type, for Access type, choose Programmatic access. Then choose Next:

Permissions.

5. Under Set permissions, choose Attach existing policies directly. In the list of policies, choose the policy that you created in Step 1.1 (p. 4). Then choose Next: Tags.

6. On the Add tags page, optionally add tags that help you identify the user. For more information about using tags, see Tagging IAM users and roles in the IAM User Guide. Then choose Next: Review.

7. On the Review page, review and confirm the settings for the user. When you're ready to create the user, choose Create user.

8. On the Success page, copy the credentials that are shown in the Access key ID and Secret access key columns.

NoteYou need to provide both the access key ID and the secret access key later in this tutorial.

This is the only time that you're able to view the secret access key, so you should copy it and save it in a safe location.

Step 2: Set up Postman

Now that you've created an IAM user account that's able to access the Amazon Pinpoint API, you can set up Postman. In this section, you create one or more environments in Postman. Next, you import a collection that contains a request template for each of the operations in the Amazon Pinpoint API.

Step 2.1: Create Postman environments

In Postman, an environment is a set of variables that are stored as key-value pairs. You can use environments to quickly change the configuration of the requests that you make through Postman, without having to change the API requests themselves.

In this section, you create at least one environment to use with Amazon Pinpoint. Each environment that you create contains a set of variables that are specific to your account in a single AWS Region. If you use the procedures in this section to create more than one environment, you can easily change between Regions by choosing a different environment from the Environment menu in Postman.

To create an environment

1. In Postman, on the File menu, choose New.

2. On the Create New window, choose Environment.

3. On the MANAGE ENVIRONMENTS window, for Environment Name, enter Amazon Pinpoint -Region Name. Replace Region Name with one of the following values:

• US East (N. Virginia)

• US West (Oregon)

Step 2: Set up Postman

• Asia Pacific (Mumbai)

• Asia Pacific (Sydney)

• Europe (Frankfurt)

• Europe (Ireland)

4. Create six new variables: endpoint, region, serviceName, accountId, accessKey, and secretAccessKey. Use the following table to determine which value to enter in the Initial Value column for each variable.

Region Variable Initial value

endpoint

pinpoint.us-east-1.amazonaws.com

region us-east-1

serviceName mobiletargeting

accountId (your AWS account ID)

accessKey (your IAM access key ID)

US East (N. Virginia)

secretAccessKey (your IAM secret access key)  

endpoint

pinpoint.us-west-2.amazonaws.com

region us-west-2

serviceName mobiletargeting

accountId (your AWS account ID)

accessKey (your IAM access key ID)

US West (Oregon)

secretAccessKey (your IAM secret access key)  

endpoint

pinpoint.ap-south-1.amazonaws.com

region ap-south-1

serviceName mobiletargeting

accountId (your AWS account ID)

accessKey (your IAM access key ID)

Asia Pacific (Mumbai)

secretAccessKey (your IAM secret access key)  

endpoint

pinpoint.ap-southeast-2.amazonaws.com Asia Pacific (Sydney)

region ap-southeast-2

Step 2: Set up Postman

Region Variable Initial value

serviceName mobiletargeting

accountId (your AWS account ID)

accessKey (your IAM access key ID)

secretAccessKey (your IAM secret access key)  

endpoint

pinpoint.eu-central-1.amazonaws.com

region eu-central-1

serviceName mobiletargeting

accountId (your AWS account ID)

accessKey (your IAM access key ID)

Europe (Frankfurt)

secretAccessKey (your IAM secret access key)  

endpoint

pinpoint.eu-west-1.amazonaws.com

region eu-west-1

serviceName mobiletargeting

accountId (your AWS account ID)

accessKey (your IAM access key ID)

Europe (Ireland)

secretAccessKey (your IAM secret access key)

After you create these variables, the MANAGE ENVIRONMENTS window resembles the example shown in the following image.

Step 2: Set up Postman

When you finish, choose Add.

Important

The access keys shown in the preceding image are fictitious. Never share your IAM access keys with others.

Postman includes features that enable you to share and export environments. If you use these features, be careful to not share your access key ID and secret access key with anybody who shouldn't have access to these credentials.

For more information, see IAM best practices in the IAM User Guide.

5. (Optional) Repeat steps 1–4 for each additional environment that you want to create.

TipIn Postman, you can create as many environments as you need. You can use environments in several ways. For example, you can do all of the following:

• Create a separate environment for every Region where you need to test the Amazon Pinpoint API.

• Create environments that are associated with different AWS accounts.

• Create environments that use credentials that are associated with other IAM users.

6. When you finish creating environments, proceed to the next section.

Step 2.2: Create an Amazon Pinpoint collection in Postman

In Postman, a collection is a group of API requests. Requests in a collection are typically united by a common purpose. In this section, you create a new collection that contains a request template for each operation in the Amazon Pinpoint API.

Step 2: Set up Postman

To create the Amazon Pinpoint collection 1. In Postman, on the File menu, choose Import.

2. On the Import window, choose Import From Link, and then enter the following URL: https://

raw.githubusercontent.com/awsdocs/amazon-pinpoint-developer-guide/master/Amazon

%20Pinpoint.postman_collection.json.

Choose Import. Postman imports the Amazon Pinpoint collection, which contains 120 example requests.

Step 2.3: Test your Postman configuration

After you import the Amazon Pinpoint collection, you should perform a quick test to make sure that all of the components are properly configured. You can test your configuration by submitting a GetApps request. This request returns a list of all of the projects that exist in your Amazon Pinpoint account in the current AWS Region. This request doesn't require any additional configuration, so it's a good way to quickly test your configuration.

To test the configuration of the Amazon Pinpoint collection

1. In the navigation pane, expand the Amazon Pinpoint collection, and then expand the Apps folder.

2. In the list of requests, choose GetApps.

3. Use the Environment selector to choose the environment that you created in Step 2.1 (p. 6), as shown in the following image.

Step 2: Set up Postman

4. Choose Send. If the request is sent successfully, the response pane shows a status of 200 OK. You see a response that resembles the example in the following image.

This response shows a list of all of the Amazon Pinpoint projects that exist in your account in the Region that you chose in step 3.

Troubleshooting

When you submit your request, you might see an error. See the following list for several common errors that you might encounter, and for steps that you can take to resolve them.

Error message Problem Resolution

Could not get any response There was an error connecting to https://%7B%7Bendpoint%7D

%7D/v1/apps.

There is no current value for the {{endpoint}} variable, which is set when you choose an environment.

Use the environment selector to choose an environment.

The security token included in

the request is invalid. Postman wasn't able to find the current value of your access key ID or secret access key.

Choose the gear icon near the environment selector, and then choose the current environment.

在文檔中 Amazon Pinpoint (頁 13-19)

相關文件