mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Beeminder Node): Remove unnecessary form data conversion for API token auth to work (#18133)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,26 +15,6 @@ function isValidAuthenticationMethod(value: unknown): value is 'apiToken' | 'oAu
|
||||
return typeof value === 'string' && ['apiToken', 'oAuth2'].includes(value);
|
||||
}
|
||||
|
||||
function convertToFormData(obj: any): Record<string, string> {
|
||||
const result: Record<string, string> = {};
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value === null || value === undefined) {
|
||||
// Skip null/undefined values
|
||||
continue;
|
||||
} else if (typeof value === 'boolean') {
|
||||
result[key] = value.toString();
|
||||
} else if (typeof value === 'number') {
|
||||
result[key] = value.toString();
|
||||
} else if (Array.isArray(value)) {
|
||||
// Handle arrays - convert to JSON string for form data
|
||||
result[key] = JSON.stringify(value);
|
||||
} else {
|
||||
result[key] = String(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function beeminderApiRequest(
|
||||
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
@@ -42,7 +22,6 @@ export async function beeminderApiRequest(
|
||||
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
useFormData: boolean = false,
|
||||
): Promise<any> {
|
||||
const authenticationMethod = this.getNodeParameter('authentication', 0, 'apiToken');
|
||||
|
||||
@@ -57,23 +36,14 @@ export async function beeminderApiRequest(
|
||||
|
||||
const options: IRequestOptions = {
|
||||
method,
|
||||
body,
|
||||
qs: query,
|
||||
uri: `${BEEMINDER_URI}${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (useFormData) {
|
||||
options.formData = convertToFormData(body);
|
||||
} else {
|
||||
options.body = body;
|
||||
}
|
||||
|
||||
if (!Object.keys(body as IDataObject).length) {
|
||||
if (useFormData) {
|
||||
delete options.formData;
|
||||
} else {
|
||||
delete options.body;
|
||||
}
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
if (!Object.keys(query).length) {
|
||||
|
||||
Reference in New Issue
Block a user