From db5bf69fd39a6b3402080d99259e88019afab30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Sat, 17 Apr 2021 09:59:11 +0200 Subject: [PATCH] :bug: Fix AWS SQS API version and casing (#1630) * :wrench: Add API version and adjust casing * :hammer: Refactor query string params into array * :hammer: Add API version to resource loader Co-authored-by: Jan Oberhauser --- .../nodes-base/nodes/Aws/SQS/AwsSqs.node.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts index 63a5dd4ff9..38d02abf43 100644 --- a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts +++ b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts @@ -1,5 +1,4 @@ import { - BINARY_ENCODING, IExecuteFunctions, } from 'n8n-core'; @@ -23,6 +22,10 @@ import { awsApiRequestSOAP, } from '../GenericFunctions'; +import { + pascalCase, +} from 'change-case'; + export class AwsSqs implements INodeType { description: INodeTypeDescription = { displayName: 'AWS SQS', @@ -268,10 +271,15 @@ export class AwsSqs implements INodeType { loadOptions: { // Get all the available queues to display them to user so that it can be selected easily async getQueues(this: ILoadOptionsFunctions): Promise { + const params = [ + 'Version=2012-11-05', + `Action=ListQueues`, + ]; + let data; try { // loads first 1000 queues from SQS - data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?Action=ListQueues`); + data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?${params.join('&')}`); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -310,7 +318,11 @@ export class AwsSqs implements INodeType { for (let i = 0; i < items.length; i++) { const queueUrl = this.getNodeParameter('queue', i) as string; const queuePath = new URL(queueUrl).pathname; - const params = []; + + const params = [ + 'Version=2012-11-05', + `Action=${pascalCase(operation)}`, + ]; const options = this.getNodeParameter('options', i, {}) as IDataObject; const sendInputData = this.getNodeParameter('sendInputData', i) as boolean; @@ -375,7 +387,7 @@ export class AwsSqs implements INodeType { let responseData; try { - responseData = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `${queuePath}/?Action=${operation}&` + params.join('&')); + responseData = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `${queuePath}?${params.join('&')}`); } catch (error) { throw new NodeApiError(this.getNode(), error); }