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 Script for Amazon SP API

Method – POST


1
import time
2
import datetime, hashlib, hmac
3
import json
4
access_key='{{access_key}}'                 # Provide Values     
5
secret_key='{{secret_key}}'                 # Provide Values
6
host = '{{host}}'                           # Provide Values
7
endpoint = '{{hostname}}'                   # Provide Values
8
canonical_uri = '{{canonical_uri}}'         # Provide Values
9
body = {{body}}                             # Provide Values
10
##########################################################################################################################################################
11
request_parameters =json.dumps(body)
12
t = datetime.datetime.utcnow()
13
amzdate = t.strftime('%Y%m%dT%H%M%SZ')
14
datestamp = t.strftime('%Y%m%d')
15
method = 'POST'
16
service = 'execute-api'
17
region = 'us-east-1'
18
canonical_querystring = ''
19
canonical_headers = 'host:' + host + '\\n' + 'x-amz-date:' + amzdate + '\\n'
20
signed_headers = 'host;x-amz-date'
21
payload_hash = hashlib.sha256((request_parameters).encode('utf-8')).hexdigest()
22
canonical_request = method + '\\n' + canonical_uri + '\\n' + canonical_querystring + '\\n' + canonical_headers + '\\n' + signed_headers + '\\n' + payload_hash
23
algorithm = 'AWS4-HMAC-SHA256'
24
credential_scope = datestamp + '/' + region + '/'+ service + '/' + 'aws4_request'
25
string_to_sign = algorithm + '\\n' +  amzdate + '\\n' +  credential_scope + '\\n' +  hashlib.sha256(canonical_request.encode('utf-8')).hexdigest()
26
kDate = hmac.new(('AWS4' + secret_key).encode('utf-8'), datestamp.encode('utf-8'), hashlib.sha256).digest()
27
kRegion = hmac.new(kDate, region.encode('utf-8'), hashlib.sha256).digest()
28
kService = hmac.new(kRegion, service.encode('utf-8'), hashlib.sha256).digest()
29
kSigning = hmac.new(kService, 'aws4_request'.encode('utf-8'), hashlib.sha256).digest()
30
signing_key = kSigning
31
signature = hmac.new(signing_key, (string_to_sign).encode('utf-8'), hashlib.sha256).hexdigest()
32
authorization_header = algorithm + ' ' + 'Credential=' + access_key + '/' + credential_scope + ', ' +  'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + signature

Method – POST (with Body)


1
import time
2
import datetime, hashlib, hmac
3
import json
4
access_key='XXXXXXXXXXXXXXXXXX'
5
secret_key='XXXXXXXXXXXXXXXXXX'
6
method = 'POST'
7
service = 'execute-api'
8
host = 'sellingpartnerapi-na.amazon.com'
9
region = 'us-east-1'
10
endpoint = 'https://sellingpartnerapi-na.amazon.com'
11
body = {'reportType': 'GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL','dataStartTime': '{%yesterday%}T00:00:01','dataEndTime': '{%yesterday%}T23:59:59','marketplaceIds': ['XXXXXXXXXX']}
12
request_parameters =json.dumps(body)
13
t = datetime.datetime.utcnow()
14
amzdate = t.strftime('%Y%m%dT%H%M%SZ')
15
datestamp = t.strftime('%Y%m%d')
16
canonical_uri = '/reports/2021-06-30/reports'
17
canonical_querystring = ''
18
canonical_headers = 'host:' + host + '\\n' + 'x-amz-date:' + amzdate + '\\n'
19
signed_headers = 'host;x-amz-date'
20
payload_hash = hashlib.sha256((request_parameters).encode('utf-8')).hexdigest()
21
canonical_request = method + '\\n' + canonical_uri + '\\n' + canonical_querystring + '\\n' + canonical_headers + '\\n' + signed_headers + '\\n' + payload_hash
22
algorithm = 'AWS4-HMAC-SHA256'
23
credential_scope = datestamp + '/' + region + '/'+ service + '/' + 'aws4_request'
24
string_to_sign = algorithm + '\\n' +  amzdate + '\\n' +  credential_scope + '\\n' +  hashlib.sha256(canonical_request.encode('utf-8')).hexdigest()
25
kDate = hmac.new(('AWS4' + secret_key).encode('utf-8'), datestamp.encode('utf-8'), hashlib.sha256).digest()
26
kRegion = hmac.new(kDate, region.encode('utf-8'), hashlib.sha256).digest()
27
kService = hmac.new(kRegion, service.encode('utf-8'), hashlib.sha256).digest()
28
kSigning = hmac.new(kService, 'aws4_request'.encode('utf-8'), hashlib.sha256).digest()
29
signing_key = kSigning
30
signature = hmac.new(signing_key, (string_to_sign).encode('utf-8'), hashlib.sha256).hexdigest()
31
authorization_header = algorithm + ' ' + 'Credential=' + access_key + '/' + credential_scope + ', ' +  'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + signature

Method – GET


1
import datetime, hashlib, hmac
2
host = '{{host}}'                      # Provide Values
3
endpoint = '{{hostname}}'              # Provide Values
4
access_key = '{{access_key}}'          # Provide Values
5
secret_key = '{{secret_key}}'          # Provide Values
6
canonical_uri = '{{canonical_uri}}'    # Provide Values
7
##########################################################################################################################################################
8
t = datetime.datetime.utcnow()
9
amzdate = t.strftime('%Y%m%dT%H%M%SZ')
10
datestamp = t.strftime('%Y%m%d')
11
method = 'GET'
12
service = 'execute-api'
13
region = 'us-east-1'
14
canonical_headers = 'host:' + host + '\\n' + 'x-amz-date:' + amzdate + '\\n'
15
signed_headers = 'host;x-amz-date'
16
payload_hash = hashlib.sha256(('').encode('utf-8')).hexdigest()
17
canonical_request = method + '\\n' + canonical_uri + '\\n' +canonical_headers + '\\n' + signed_headers + '\\n' + payload_hash
18
algorithm = 'AWS4-HMAC-SHA256'
19
credential_scope = datestamp + '/' + region + '/' + service + '/' + 'aws4_request'
20
string_to_sign = algorithm + '\\n' +  amzdate + '\\n' +  credential_scope + '\\n' +  hashlib.sha256(canonical_request.encode('utf-8')).hexdigest()
21
kDate = hmac.new(('AWS4' + secret_key).encode('utf-8'), datestamp.encode('utf-8'), hashlib.sha256).digest()
22
kRegion = hmac.new(kDate, region.encode('utf-8'), hashlib.sha256).digest()
23
kService = hmac.new(kRegion, service.encode('utf-8'), hashlib.sha256).digest()
24
kSigning = hmac.new(kService, 'aws4_request'.encode('utf-8'), hashlib.sha256).digest()
25
signing_key = kSigning
26
signature = hmac.new(signing_key, (string_to_sign).encode('utf-8'), hashlib.sha256).hexdigest()
27
authorization_header = algorithm + ' ' + 'Credential=' + access_key + '/' + credential_scope + ', ' +  'SignedHeader
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 DBPre- Request Scripts
Table of Contents
  • Method - POST
  • Method - POST (with Body)
  • Method - GET
© Copyright 2025 Bizdata Inc. | All Rights Reserved | Terms of Use | Privacy Policy