Skip to the content

Automate Everything !

🤖 Explore with AI: ChatGPT Perplexity Claude Google AI Grok

For Enterprises | Teams | Start-Ups

eZintegrations – AI Workflows & AI Agents Automation Hub

eZintegrations – AI Workflows & AI Agents Automation Hub

Automate to Innovate

0
$0.00
eZintegrations – AI Workflows & AI Agents Automation Hub

eZintegrations – AI Workflows & AI Agents Automation Hub

Automate to Innovate

Menu
0
$0.00
  • Categories
    • Workflow Automation
    • AI Workflow
    • AI Agent
    • Agentic AI
  • Home
  • Automate Now !
  • About Us
  • Contact
  • Blog
  • Free AI Workflow
  • Free AI Agents

eZintegrations

  • eZintegrations Introduction
  • Data Source API
    • Response Parameters: Text, XML, and JSON Formats
    • Environment Settings for Reusable and Dynamic Configuration
    • API Numeric Parameters for Pagination and Record Limits
    • API Time Parameters for Date and Time-Based Data Filtering
    • Authorization
    • How to test the Data Source API
    • Pre- Request Scripts
      • Pre- Request Scripts for Amazon S3
      • Pre- Request Scripts for Azure Cosmos DB
      • Pre-Request Script for Amazon SP API
      • Pre- Request Scripts
    • API Pagination Methods
      • Custom Pagination
      • Encoded Next Token Pagination
      • Cursor Pagination
      • Pagination with Body
      • Total Page Count Pagination
      • Offset Pagination
      • Next URL Pagination
      • API Pagination Introduction
      • Pagination examples
        • SAP Shipment API Pagination
        • Amazon SP API Pagination

Goldfinch AI

  • Goldfinch AI Introduction

Bizdata API

  • Universal API for Database
    • API for PostgreSQL Database – Universal API
    • API for Amazon Aurora Database (MySQL/Maria) – Universal API
    • API for Amazon Redshift Database – Universal API
    • API for Snowflake Database – Universal API
    • API for MySQL/Maria Database – Universal API
    • API for MS-SQL Database-Universal API
    • API for Oracle Database- Universal API
    • Introduction to Universal API for Databases
  • SFTP API
    • SFTP API
  • Document Understanding APIs
    • Document Understanding API- Extract data from Documents
  • Web Crawler API
    • Web Crawler API – Fast Website Scraping
  • AI Workflow Testing APIs
    • Netsuite Source Testing API (Netsuite API Replica)
    • Salesforce Testing API (Salesforce API replica)
    • OAuth2.0 Testing API 
    • Basic Auth Testing API 
    • No Auth Testing API
    • Pagination with Body Testing API
    • Next URL Pagination Testing API 
    • Total Page Count Pagination Testing API
    • Cursor Pagination Testing API 
    • Offset Pagination Testing API
  • Import IB API
    • Import IB API
  • Linux File & Folder Monitoring APIs
    • Linux File & Folder Monitoring APIs
  • Webhook
    • Webhook Integration-Capture Events in Real Time
  • Websocket
    • Websocket Integration- Fetch Real Time Data
  • Image Understanding
    • Image Understanding API – Extract data from Images
View Categories

Pre- Request Scripts for Amazon S3

Amazon S3

Method : PUT

Note: This pre_request_script is for loading data to Amazon S3 Bucket.


1
import hashlib
2
import hmac
3
import datetime
4
access_key = '{{access_key}}'         # Provide Values
5
secret_key = '{{secret_key}}'         # Provide Values
6
bucket = '{{bucket_name}}'            # Provide Values
7
region = '{{region}}'                 # Provide Values
8
payload = '''{{payload}}'''           # Provide Values
9
host = '{{host}}'                     # Provide Values
10
canonical_uri = '/{{canonical_uri}}'  # Provide Values
11
################################################################################################################################################################################
12
method = 'PUT'
13
amzdate = datetime.datetime.utcnow().strftime('%Y%m%dT%H%M%SZ')
14
datestamp = datetime.datetime.utcnow().strftime('%Y%m%d')
15
canonical_querystring = ''
16
payload_hash = hashlib.sha256(payload.encode()).hexdigest()
17
canonical_headers = 'host:' + host + '\\n' + 'x-amz-content-sha256:' + payload_hash + '\\n' + 'x-amz-date:' + amzdate + '\\n'
18
signed_headers = 'host;x-amz-content-sha256;x-amz-date'
19
canonical_request = method + '\\n' + canonical_uri + '\\n' + canonical_querystring + '\\n' + canonical_headers + '\\n' + signed_headers + '\\n' + hashlib.sha256(payload.encode()).hexdigest()
20
algorithm = 'AWS4-HMAC-SHA256'
21
credential_scope = datestamp + '/' + region + '/s3/aws4_request'
22
string_to_sign = algorithm + '\\n' + amzdate + '\\n' + credential_scope + '\\n' + hashlib.sha256(canonical_request.encode()).hexdigest()
23
date_key = hmac.new(('AWS4' + secret_key).encode(), datestamp.encode(), hashlib.sha256).digest()
24
region_key = hmac.new(date_key, region.encode(), hashlib.sha256).digest()
25
service_key = hmac.new(region_key, 's3'.encode(), hashlib.sha256).digest()
26
signing_key = hmac.new(service_key, 'aws4_request'.encode(), hashlib.sha256).digest()
27
signature = hmac.new(signing_key, string_to_sign.encode(), hashlib.sha256).hexdigest()
28
authorization_header = algorithm + ' Credential=' + access_key + '/' + credential_scope + ', SignedHeaders=' + signed_headers + ', Signature=' + signature

Method : GET

Note: This pre_request_script is for retrieving data from Amazon S3 Bucket.


1
import hashlib
2
import hmac
3
import datetime
4
access_key = '{{access_key}}'         # Provide Values
5
secret_key = '{{secret_key}}'         # Provide Values
6
bucket = '{{bucket_name}}'            # Provide Values
7
region = '{{region}}'                 # Provide Values
8
host = '{{host}}'                     # Provide Values
9
canonical_uri = '/{{canonical_uri}}'  # Provide Values
10
##################################################################################################################################################################################
11
method = 'GET'
12
service = 's3'
13
t = datetime.datetime.utcnow()
14
amzdate = t.strftime('%Y%m%dT%H%M%SZ')
15
datestamp = t.strftime('%Y%m%d')
16
canonical_querystring = ''
17
canonical_headers = 'host:' + host + '\n' + 'x-amz-date:' + amzdate + '\n'
18
signed_headers = 'host;x-amz-date'
19
payload_hash = hashlib.sha256(('').encode('utf-8')).hexdigest()
20
canonical_request = method + '\n' + canonical_uri + '\n' + canonical_querystring + '\n' + canonical_headers + '\n' + signed_headers + '\n' + payload_hash
21
algorithm = 'AWS4-HMAC-SHA256'
22
credential_scope = datestamp + '/' + region + '/'+ service + '/' + 'aws4_request'
23
string_to_sign = algorithm + '\n' +  amzdate + '\n' +  credential_scope + '\n' +  hashlib.sha256(canonical_request.encode('utf-8')).hexdigest()
24
date_key = hmac.new(("AWS4" + secret_key).encode(), datestamp.encode(), hashlib.sha256).digest()
25
region_key = hmac.new(date_key, region.encode(), hashlib.sha256).digest()
26
service_key = hmac.new(region_key, "s3".encode(), hashlib.sha256).digest()
27
signing_key = hmac.new(service_key, "aws4_request".encode(), hashlib.sha256).digest()
28
signature = hmac.new(signing_key, (string_to_sign).encode('utf-8'), hashlib.sha256).hexdigest()
29
authorization_header = algorithm + ' ' + 'Credential=' + access_key + '/' + credential_scope + ', ' +  'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + signature
Updated on December 10, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest
Pre- Request Scripts for Azure Cosmos DB
Table of Contents
  • Amazon S3
    • Method : PUT
    • Method : GET
© Copyright 2025 Bizdata Inc. | All Rights Reserved | Terms of Use | Privacy Policy