SignString
The SignString is generated by Method, Uri, Headers, Body from a HTTP(s) request.
Required string
Key | Description | Example |
---|---|---|
method | HTTP method | PUT GET POST |
content_md5 | Computed MD5 hash of the request body in uppercase hex format. If the request body is empty, set content_md5 to an empty string. | 875264590688CA6171F6228AF5BBB3D2 |
content_type | Content type string. If the request body is empty, set content_type to an empty string. | application/json |
date | UTC time in RFC 1123 format. Kindly note that the calculated signature is only valid for 3 minutes before or after the datetime indicated in this key. | Sun, 06 Nov 1994 08:49:37 GMT |
canonicalized_headers | See below for the specification. If no customized header is provided, set canonicalized_headers to an empty string | as-api-key:c25b1e6fee2348b3a8bd21599b6ac2de |
canonicalized_resource | Resource Uri, See below for the specification. | /commerce/v1/products |
canonicalized_headers
To generate the canonicalized_headers:
-
Extract all request headers with the
as-
prefix key. Kindly note that the headers with theas-
prefix are not limited toas-api-key
, but also include otheras-
prefixed key such asas-store-id
. -
Convert all the request header key to lowercase (except the header values case), and sort the headers in ASCII code order.
-
Remove leading spaces and trailing spaces from the header key and value.
-
Concatenate each of the header key and value with
:
, to form aheader pair
preparing... -
Concatenate all header pairs with the new line character (ASCII code
10
).
Example
Original Header | canonicalized_headers |
---|---|
AS-header2: ThisIsHeader2\nAS-Header1: this-is-header-1 | as-header1:this-is-header-1\nas-header2:ThisIsHeader2 |
canonicalized_resource
canonicalized_resource is the path of the URL, including the query parameters.
Simple Path
Example
https://api.aftership.com/admin/2022-01/some-resources
canonicalized_resource
/admin/2022-01/some-resources
With query parameter
If there is any parameter, it should be appended to the path.
The parameters should be sorted by the ASCII code of the key in ascending order, and parameters with duplicate names should be sorted by the value.
Example
https://api.aftership.com/admin/2022-01/some-resources?key2=value2&key1=value1
canonicalized_resource
/admin/2022-01/some-resources?key1=value1&key2=value2
Output
The SignString is constructed by concatenating all the required keys with the new line character (ASCII code 10
).
Make sure the string encoding is in UTF-8
.