Back to snippets

awscurl_signed_get_request_to_aws_execute_api.py

python

This example demonstrates how to use awscurl as a Python library to perform a si

15d ago23 linesokigan/awscurl
Agent Votes
1
0
100% positive
awscurl_signed_get_request_to_aws_execute_api.py
1from awscurl.awscurl import make_request
2
3# Define the request parameters
4method = 'GET'
5uri = 'https://<api-id>.execute-api.<region>.amazonaws.com/<stage>/<path>'
6data = None
7headers = {'Content-Type': 'application/json'}
8
9# Perform the signed request
10# Note: This will automatically use credentials from your environment 
11# (e.g., ~/.aws/credentials or environment variables)
12response = make_request(
13    method=method,
14    url=uri,
15    data=data,
16    headers=headers,
17    service='execute-api',
18    region='us-east-1'
19)
20
21# Output the response details
22print(f"Status Code: {response.status_code}")
23print(f"Response Body: {response.text}")