diff --git a/Common/Server/Types/Workflow/Components/API/Post.ts b/Common/Server/Types/Workflow/Components/API/Post.ts index d16cdf4167..7141d8d872 100644 --- a/Common/Server/Types/Workflow/Components/API/Post.ts +++ b/Common/Server/Types/Workflow/Components/API/Post.ts @@ -11,6 +11,7 @@ import ComponentMetadata, { Port } from "Common/Types/Workflow/Component"; import ComponentID from "Common/Types/Workflow/ComponentID"; import APIComponents from "Common/Types/Workflow/Components/API"; import API from "Common/Utils/API"; +import logger from "../../../../Utils/Logger"; export default class ApiPost extends ComponentCode { public constructor() { @@ -38,6 +39,25 @@ export default class ApiPost extends ComponentCode { let apiResult: HTTPResponse | HTTPErrorResponse | null = null; + logger.debug("API Post Component is running."); + + const url: URL = args["url"] as URL; + if (!url) { + throw options.onError(new BadDataException("URL is required")); + } + + logger.debug(`URL: ${url}`); + + const requestBody: JSONObject = args["request-body"] as JSONObject; + + logger.debug(`Request Body: ${JSON.stringify(requestBody)}`); + + const requestHeaders: Dictionary = args[ + "request-headers" + ] as Dictionary; + + logger.debug(`Request Headers: ${JSON.stringify(requestHeaders)}`); + try { apiResult = await API.post( args["url"] as URL, @@ -45,6 +65,8 @@ export default class ApiPost extends ComponentCode { args["request-headers"] as Dictionary, ); + logger.debug("API Post Component is done."); + return Promise.resolve({ returnValues: ApiComponentUtils.getReturnValues(apiResult), executePort: result.successPort, @@ -64,6 +86,9 @@ export default class ApiPost extends ComponentCode { }); } + logger.debug("API Post Component is done with error."); + logger.debug(err); + throw options.onError(new APIException("Something wrong happened.")); } }