Postman Cloud API Script
This is a script created by Development for Cloud API on Postman.
Steps
* Please Duplicate the API call and add it to a private collection. This is a public collection that we share with all Aqua customers so DO NOT ADD OR SAVE ANY PRIVATE CREDENTIALS! |
Script:
*Important to note: The below script is an example of 'Remediations' and should be changed accordingly on desired API call.
{"info":{"_postman_id":"400b3ea5-5175-4b5c-b20a-b6acab8635ce","name":"Aqua CSPM Public Collection","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json"},"item":[{"name":"pre-request-script","event":[{"listen":"prerequest","script":{"type":"text/javascript","exec":["var crypto = require('crypto-js');","var moment = require('moment');","","var secret = \"replace_with_secret\";","","var timestamp = (moment.unix(new Date()))/1000;","let path = pm.request.url.getPath();","let method = pm.request.method.toUpperCase();","","let body = JSON.parse(pm.request.body.raw);","","var string = timestamp + method + path + (body && Object.keys(body).length > 0 ? JSON.stringify(body) : '');","","var hmac = crypto.HmacSHA256(string, secret);","var signature = hmac.toString();","","pm.globals.set(\"signature\", signature);","pm.globals.set(\"timestamp\", timestamp);"]}}],"id":"233a8a91-2d8a-4aa9-934b-f162aa8e996b","request":{"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","type":"text"},{"key":"X-Signature","value":"{{signature}}","type":"text"},{"key":"X-Timestamp","value":"{{timestamp}}","type":"text"},{"key":"X-API-Key","value":"pLMA2P4LKPkuCUcTk8btyB","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n \"result_ids\": [123, 456],\n \"token_code\": \"123456\"\n}","options":{"raw":{"language":"json"}}},"url":"https://api.cloudsploit.com/v2/remediations"},"response":[]}]}
Important to Change in Script
- In the 'headers' change the API key
- In the 'body; change the body to be what is needed
- In the 'pre-request script' change the 'secret'
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.