16 Aug 2024 02:22 PM
Hi Folks,
Need some help in writing a JS code for workflow.
I'm using "Issue an HTTP request to any API" call to fetch the response and I wanted to objects from this response to next "Issue an HTTP request to any API" call.
As far as I know, we cannot pass objects directly from "Issue an HTTP request to any API" call to next step/call. We have to use "Build a custom task running js Code" to store the values/objects and use for next step or API call.
The body for first API call comprises of,
{
"objectId": "abscdf",
"summary": "",
"searchSummary": "",
"created": 12345677,
"modified": 78901234,
"createdBy": "elstfsvs",
"modifiedBy": "elstfsvs",
"author": "someone@test.com",
"updateToken": "123456absbdsld",
"scope": "APPLICATION-123456xyz",
"schemaId": "builtin:rum.web.rum-javascript-updates",
"schemaVersion": "1.1",
"resourceContext": {
"operations": [
"read",
"write",
"delete"
],
"modifications": {
"movable": true,
"modifiablePaths": [],
"nonModifiablePaths": []
}
},
"value": {
"JavascriptVersion": "CUSTOM"
}
}
Based on JavascriptVersion, I wanted to pass application ID to next request which is actually POST api call.
I tried to write the below JS code, I'm able to get whole response body but how do I get those objects and pass it on to next API call.
// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function({execution_id}) {
const ex = await execution(execution_id);
const data = await ex.result('check_rum_version');
console.log(data);
}
Can someone help here.
Regards,
AK
Solved! Go to Solution.
16 Aug 2024 10:14 PM
Can somebody please share some thoughts on this.
18 Aug 2024 07:30 PM
I'm able to get this with below code.
// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function({execution_id}) {
const ex = await execution(execution_id);
const data = await ex.result('check_rum_version');
const Scope = data[0].json.scope;
return Scope;
console.log(Scope);
}
Regards,
AK