Created on 12-01-2020 02:20 AM - last edited on 12-01-2020 02:25 AM by VidyaSargur
Hello everyone,
I am trying to authenticate with InvokeHttp NiFi Processor to Salesforce by using Bulk API v2 and with OAuth 2.0 :
The InvokeHttp Processor is configured as follow :
The Remote URL is made by using this syntax:
https://< mydomain >.salesforce.com/services/oauth2/token?grant_type=password&client_id=<client_id>&client_secret=<client_secret>&username=<username>&password=<password + key>
As we are using the HTTPS protocol, we add a “SSL Context Service” by setting a new “SSL Context Controller Service”:
And the Post request is already tested and worked with Postman tool, by responding with an authentication token.
The blocking point for this use case is that, with InvokeHTTP NIFI Processor we have not been able to get a response from the Bulk API ( the first image show that we never receive any response from Salesforce )
If you have any suggestion, it's will be helpful.
Thank you in advance
KSAD
Created 12-02-2020 12:26 AM
@stevenmatisonthe solution that i find is to get the Oauth2 token from slaesforec by using command Curl. like is explained in this page : https://www.jitendrazaa.com/blog/salesforce/using-curl-with-salesforce-rest-api/
So i create a ExecuteProces NiFi Procesor. And as parameter i put :
the file C:/loginInfo.txt contains :
grant_type=password&
client_id= 3MVG9iTxZANhwsdsdsdsdspr0LstjR3sRat &
client_secret=21961212323233121943 & username=jitendra.zaa@demo.com &
password=myPWDAndSecurityToken
and the i get a response with the authentication token 🙂
(you can use the cmd command Curl -x post -d @LoginInfo.txt Https://test.salesforce.com/.... to test the connection between the local machine and salesforce )
Created 12-01-2020 05:09 AM
@Ksad Excellent work to completely show us what you have. Also, excellent work to test and confirm your request work in postman first. This is always one of the first things I do to make sure i have a valid test connection and all settings to connect to the API before attempting with InvokeHttp. When you take this route, and you cannot get a response, this indicates a networking issue with Nifi to [salesforce domain]. You should test command line from NiFi node to [salesforce domain] using curl, wget, telnet, etc. Next if you can confirm connectivity, attempt to adjust the processor time outs. Some systems need longer than defaults. For example I sometimes set to 50 and 150 by just adding a 0 to the 2 values (connection and read timeout). f it did time out it should throw an error. You can also set the processor log level to debug to expose more verbose output in the NiFi UI. Last but not least, tail the nifi-app.log file while doing all nifi flow debugging. Sometimes more useful information is found there.
If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.
Thanks,
Steven
Created 12-01-2020 06:59 AM
Thank you @stevenmatison for the quick answer.
The connection between my local machine (where NiFi is installed and executed) and salesforce server is working well, because i already tried with postman and it is working.
also, I increased the timeout as shown in the image below :
and also activate the logging to debug level :
But still have no output inthe Bulltin board of NiFi.
I let it run for 2minutes and had this log lines from the app.log file :
i an wondering if there a parameter to add for the InvokeHttp processor like "authorization:OAuth2" or other ?
Thank you
Created 12-01-2020 07:49 AM
You can leverage "Attributes to send" or if you stop processor and click + you can add custom attributes right on bottom of processor config. If you are not getting anything out of response (failure, retry, no-retry, etc) then you definitely have a connectivity issue from Nifi outbound...
Created on 12-01-2020 08:40 AM - edited 12-01-2020 08:43 AM
Hi @stevenmatison , by using Curl command with my local machine , the authentication on salesforce is working and i get a token:
And i already try the SOAP connection to Salesforce and it is working also. But with Oauth2.0 is not 😕
So the problem is on NiFi InvokeHTTP Processor
Created 12-02-2020 12:26 AM
@stevenmatisonthe solution that i find is to get the Oauth2 token from slaesforec by using command Curl. like is explained in this page : https://www.jitendrazaa.com/blog/salesforce/using-curl-with-salesforce-rest-api/
So i create a ExecuteProces NiFi Procesor. And as parameter i put :
the file C:/loginInfo.txt contains :
grant_type=password&
client_id= 3MVG9iTxZANhwsdsdsdsdspr0LstjR3sRat &
client_secret=21961212323233121943 & username=jitendra.zaa@demo.com &
password=myPWDAndSecurityToken
and the i get a response with the authentication token 🙂
(you can use the cmd command Curl -x post -d @LoginInfo.txt Https://test.salesforce.com/.... to test the connection between the local machine and salesforce )