mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(ERPNext Node): Fix issue with credential test and add frappe cloud url (#6283)
This commit is contained in:
parent
37506050c3
commit
2a2b6452dc
|
@ -56,6 +56,28 @@ export class ERPNextApi implements ICredentialType {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Domain',
|
||||||
|
name: 'domain',
|
||||||
|
type: 'options',
|
||||||
|
default: 'erpnext.com',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'erpnext.com',
|
||||||
|
value: 'erpnext.com',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'frappe.cloud',
|
||||||
|
value: 'frappe.cloud',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
description: 'Domain for your cloud hosted ERPNext instance.',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
environment: ['cloudHosted'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Domain',
|
displayName: 'Domain',
|
||||||
name: 'domain',
|
name: 'domain',
|
||||||
|
@ -90,9 +112,19 @@ export class ERPNextApi implements ICredentialType {
|
||||||
test: ICredentialTestRequest = {
|
test: ICredentialTestRequest = {
|
||||||
request: {
|
request: {
|
||||||
baseURL:
|
baseURL:
|
||||||
'={{$credentials.environment === "cloudHosted" ? "https://" + $credentials.subdomain + ".erpnext.com" : $credentials.domain}}',
|
'={{$credentials.environment === "cloudHosted" ? "https://" + $credentials.subdomain + "." + $credentials.domain : $credentials.domain}}',
|
||||||
url: '/api/resource/Doctype',
|
url: '/api/method/frappe.auth.get_logged_user',
|
||||||
skipSslCertificateValidation: '={{ $credentials.allowUnauthorizedCerts }}',
|
skipSslCertificateValidation: '={{ $credentials.allowUnauthorizedCerts }}',
|
||||||
},
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
type: 'responseSuccessBody',
|
||||||
|
properties: {
|
||||||
|
key: 'message',
|
||||||
|
value: undefined,
|
||||||
|
message: 'Unable to authenticate, Check the credentials and the url',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { NodeApiError } from 'n8n-workflow';
|
||||||
* Return the base API URL based on the user's environment.
|
* Return the base API URL based on the user's environment.
|
||||||
*/
|
*/
|
||||||
const getBaseUrl = ({ environment, domain, subdomain }: ERPNextApiCredentials) =>
|
const getBaseUrl = ({ environment, domain, subdomain }: ERPNextApiCredentials) =>
|
||||||
environment === 'cloudHosted' ? `https://${subdomain}.erpnext.com` : domain;
|
environment === 'cloudHosted' ? `https://${subdomain}.${domain}` : domain;
|
||||||
|
|
||||||
export async function erpNextApiRequest(
|
export async function erpNextApiRequest(
|
||||||
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||||
|
|
Loading…
Reference in a new issue