diff --git a/bruno/environments/Bookhoard.yml b/bruno/environments/Bookhoard.yml index 6356cf3..52cfbd1 100644 --- a/bruno/environments/Bookhoard.yml +++ b/bruno/environments/Bookhoard.yml @@ -13,7 +13,7 @@ variables: - name: note_id value: 7710a602-g29b-61d4-c716-446655440002 - name: library_id - value: d2932c11-cd39-4c4a-b940-124b75964099 + value: dd03d719-76c8-4398-93ec-9258d2becf85 - name: job_id value: d5554991-1a13-4f60-9a70-82d19ed1abe2 - name: rating diff --git a/bruno/library/Get Libraries (Admin).yml b/bruno/library/Get Libraries (Admin).yml index cad418a..3e83a11 100644 --- a/bruno/library/Get Libraries (Admin).yml +++ b/bruno/library/Get Libraries (Admin).yml @@ -2,15 +2,43 @@ info: name: Get Libraries (Admin) type: http seq: 1 + http: method: GET - url: '{{base_url}}/api/libraries' - auth: inherit - body: - type: none + url: "{{base_url}}/api/libraries" headers: - - key: Content-Type - value: application/json + - name: "" + value: application/json + auth: inherit + +runtime: + scripts: + - type: after-response + code: |- + function onResponse(res) { + try { + const responseBody = res.getBody(); + const id = responseBody.data[0].id; + + if (id) { + bru.setEnvVar("library_id", id, { persist: true }); + console.log("Library ID saved:", id); + } + + if (!id) { + console.log("No id found in response."); + } + } catch (error) { + console.error("Error in post-response script:", error.message); + } + } + onResponse(res); + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 docs: |- ## Get Libraries (Admin)