fix: IRIS API - post request script

This commit is contained in:
2026-03-11 17:25:05 +01:00
parent 445a7d62cc
commit b51d6c2383
@@ -7,6 +7,15 @@ http:
method: GET
url: "{{IrisApiUrl}}/contracts;full?year=2025&wfState=signed&page=1"
params:
- name: year
value: "2025"
type: query
- name: wfState
value: signed
type: query
- name: page
value: "1"
type: query
- name: pid
value: BELL_B_25_CCS_IST_RA_01
type: query
@@ -39,15 +48,6 @@ http:
value: AMER_F_25_CCS_IST_RA_CODICI_01
type: query
disabled: true
- name: year
value: "2025"
type: query
- name: wfState
value: signed
type: query
- name: page
value: "1"
type: query
auth: inherit
runtime:
@@ -74,7 +74,7 @@ runtime:
// ---------------- URL and Query helpers (SDK-safe) -----------------
// Returns a plain object of query params. Works with:
// // - pm.request.url.query (SDK v8+ as QueryList) using .toObject()
// - pm.request.url.query (SDK v8+ as QueryList) using .toObject()
// - URL that has no query or is a raw string
function getQueryObject(url) {
try {
@@ -202,16 +202,23 @@ runtime:
// Build a function that fetches page N and aggregates
function fetchPage(n) {
return new Promise((resolve) => {
//console.log("Setting current page to: " + n);
const nextUrl = setQueryObject(req.getUrl(), { [PAGE_PARAM]: String(n) });
setTimeout(function () {
await bru.sendRequest({ url: nextUrl, method: 'GET' }, async function(err, res) {
const reqHeaders = req.getHeaders
console.log("Setting headers: " + JSON.stringify(reqHeaders));
setTimeout(async function () {
console.log("Calling next URL... (" + nextUrl + ")");
await bru.sendRequest({ url: nextUrl, method: 'GET', headers: reqHeaders }, async function(err, res) {
if (err || !res) {
console.log("Error fetching page " + n + " (err: " + JSON.stringify(err) + ")");
test('Error fetching page ' + n, function () {
expect(err).to.eql(null);
});
return resolve(false);
}
const ok = res.status >= 200 && res.status < 300;
console.log("Next URL response: " + ok);
if (!ok) {
test('Non-2xx on page ' + n + ' - stop further paging', function () {
expect(ok).to.eql(true);
@@ -222,13 +229,16 @@ runtime:
const json = safeJson(body);
const items = json ? getItemsFromResponseBody(json) : [];
considerItems(items);
resolve(true);
return resolve(true);
});
}, RATE_LIMIT_DELAY_MS);
});
}
async function run() {
console.log("Running...");
console.log("Total pages found: " + totalPages);
// If there are more pages, iterate
for (let p = currentPage + 1; p <= totalPages; p++) {
const cont = await fetchPage(p);
@@ -243,7 +253,7 @@ runtime:
}));
// Save to environment
bru.setEnvVar(TARGET_ENV_VAR, JSON.stringify(output));
bru.setVar(TARGET_ENV_VAR, JSON.stringify(output));
// Basic summary tests
test('Aggregated items have required properties', function () {