The Readable API has a test endpoint that I’m trying to use in a workflow but I keep getting a 400 Bad Request from the POST node.
The API documentation states that:
-
API_REQUEST_TIME
REQUIRED
The API_REQUEST_TIME
header is sent with every request to the API, and is the UNIX timestamp of the request (in the UTC timezome). The request will be rejected if the API_REQUEST_TIME
is not within the last 30 seconds.
-
API_SIGNATURE
REQUIRED
The API_SIGNATURE
header is an MD5 hash of an API key and the time you set in the API_REQUEST_TIME
header. It should change with every request.
Steps in the workflow I’ve tried.
Step 1
Create 2 date&time range:
one for 01/01/1970
one for execution time
2
Time shift execution time to get UTC time (remove British Summer time)
3
Join the 2 dates into a single table using joiner node.
4
Create a UNIX timestamp using the Date&Time difference node using seconds
5
Convert the Unix timestamp from a number to a string
6
Manipulate the string to join the testing API key with the unix timestamp.
7
Use the nodepit extension Hash calculator to convert to a MD5 hash.
8
Post the MD5 has as the API_SIGNITURE and the unixstamp as the API_REQUEST_TIME
Result!
400 Bad Request.
Note: This works perfectly well with Postman using the pre request script
// We need a UNIX timestamp to send with the request and to generate the signature
var POSTMAN_REQUEST_TIME = Math.floor(Date.now() / 1000)
// Please note this is a test key. Requests made using this key do not return real results
var POSTMAN_API_KEY = ‘THISISATESTKEYTHEREAREMANYLIKEIT’;
// Generate the API signature for this request
var POSTMAN_API_SIGNATURE = CryptoJS.MD5(POSTMAN_API_KEY + POSTMAN_REQUEST_TIME.toString()).toString();
// Set the variables we need
pm.globals.set(“POSTMAN_REQUEST_TIME”, POSTMAN_REQUEST_TIME);
pm.globals.set(“POSTMAN_API_SIGNATURE”, POSTMAN_API_SIGNATURE);
Can anyone suggest what I’m doing wrong please?
Many thanks
Binksy