Hello,
I would like to convert leads in Salesforce using convertLead() which is a SOAP API call but it seems there are solutions to achieve something similar through REST.
As describe in this stackoverflow post it seems to be possible to
“construct a one-off SOAP request to convert a lead and use the same OAuth token that you already have for the REST API.”
As explained I tried to reproduce this in the node below using predefined credential type from the Salesforce Oauth2 API integration.
However I get the following error as I can’t get value for YOUR SESSION ID (line 7)
To overcome this I tried to use a generic authentification through n8n connected app but I can’t login as I get “Something went wrong” error when trying to “connect my account”. I was aiming to do so to get information related to sessionId token.
Is it possible to get session_id value from OAuth2 predefined credential in order to pass it in the one-off SOAP request ?
If not - how can I overcome the error from generic credential I get ? Consumer and Secret Ids are correctly setup we proper scope as above.
Is someone has a better option to achieve what I’m trying to do here ?
Thanks for your help
Information on your n8n setup
n8n
March 5, 2024, 9:12am
2
It looks like your topic is missing some important information. Could you provide the following if applicable.
n8n version:
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app):
Operating system:
@Vincent_Bonjean , to get your session ID you need to use login API first. Here’s the curl command for that. Hopefully you can convert it into HTTP Request node configuration.
curl --location 'https://login.salesforce.com/services/Soap/u/50.0' \
--header 'Content-Type: text/xml' \
--header 'SOAPAction: login' \
--header 'charset: UTF-8' \
--data-raw '<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<n1:login xmlns:n1="urn:partner.soap.sforce.com">
<n1:username>YOUR_USERNAME</n1:username>
<n1:password>YOUR_PASSWORD</n1:password>
</n1:login>
</env:Body>
</env:Envelope>'
The outcome of this would be XML response like this with sessionId
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="urn:partner.soap.sforce.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<loginResponse>
<result>
<metadataServerUrl>https://IDENTIFIER.my.salesforce.com/services/Soap/m/50.0/00D0E00000057Ye</metadataServerUrl>
<passwordExpired>false</passwordExpired>
<sandbox>true</sandbox>
<serverUrl>YOUR_SALSEFORCE_URL</serverUrl>
<sessionId>00D0E00000057Ye!AQEAQA8eYhmmHy_w3JuCw6M9ZWBJOdg0AoJl0XVEKiFgn7KZSSRovJRXaVdwYoiIgC190Yd_xuMRtIJFJMgu5c5UhIdo36gt</sessionId>
<userId>YOUR_USER_ID</userId>
<userInfo>
<accessibilityMode>false</accessibilityMode>
<chatterExternal>false</chatterExternal>
<currencySymbol xsi:nil="true"/>
<orgAttachmentFileSizeLimit>5242880</orgAttachmentFileSizeLimit>
<orgDefaultCurrencyIsoCode xsi:nil="true"/>
<orgDefaultCurrencyLocale xsi:nil="true"/>
<orgDisallowHtmlAttachments>false</orgDisallowHtmlAttachments>
<orgHasPersonAccounts>false</orgHasPersonAccounts>
<organizationId>00D0E00000057YeUAI</organizationId>
<organizationMultiCurrency>true</organizationMultiCurrency>
<organizationName>Snowplow Analytics Limited</organizationName>
<profileId>00e24000000uhQyAAI</profileId>
<roleId>00E080000016U8gEAE</roleId>
<sessionSecondsValid>7200</sessionSecondsValid>
<userDefaultCurrencyIsoCode>USD</userDefaultCurrencyIsoCode>
<userEmail>YOUR_EMAIL_ADDRESS</userEmail>
<userFullName>YOUR_NAME</userFullName>
<userId>YOUR_USER_ID</userId>
<userLanguage>en_US</userLanguage>
<userLocale>en_GB</userLocale>
<userName>YOUR_USERNAME</userName>
<userTimeZone>America/Edmonton</userTimeZone>
<userType>Standard</userType>
<userUiSkin>Theme3</userUiSkin>
</userInfo>
</result>
</loginResponse>
</soapenv:Body>
</soapenv:Envelope>
To get it working, you might need to ensure n8n IP addresses are whitelisted in Salesforce Settings → Network Access.
2 Likes
system
Closed
March 13, 2024, 10:01am
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.