0

I have created a platform event trigger in salesforce and on the other hand I have a .Net APIs (with no UI) now. I want to publish a platform event from .Net API to Salesforce. Option that I explored is to use the Salesforce Rest APIs to publish the payload pertaining to that Platform Event.

Now the issue is my .Net APIs do not have the UI wherein it can authenticate the Salesforce user by entering the username and password hence I could not use the oAuth mechanism. I can't even authenticate the .Net API using the username and password of salesforce as client will not be going to share it.

Is there any other way to call Salesforce Res APIs to publish an event in Salesforce without using human intervention to add a username and a password.

  • There are oAuth flows that do not require any user interaction nor do they require a username or password. Salesforce docs cover this. – identigral Aug 5 at 0:31
  • Can you share that link – Hunt Aug 5 at 3:42
  • help.salesforce.com/… look for server-to-server – identigral Aug 5 at 15:54
0

UPDATE:

Unfortunately, there has to be a way for you to log in. Is seems unlikely that you will be able to achieve a reliable integration WITHOUT logging in. I guess you will need to talk to your client or make a call to middleware which has the credentials. Either way, you will need the credentials or atleast a way to authenticate.


This is very well documented here using the REST API. You will need a token generated via username/password and security token server to server flow without any user intervention, you can have a look at it here and for this, you will need a salesforce user with a Salesforce license.

Once you get the token, you will need to make a POST call to

<instance-url>/services/data/v49.0/sobjects/Event_Name__e/ <= Your event name.

with the body as:

{
   "Field_1__c" : "XZO-5",
   "Field_2__c" : "XZO-5"
}

The instance url is returned in the authorization call.

| improve this answer | |
  • I too had mentioned in my question that I can't even authenticate the .Net API using the username and password of salesforce as client will not be going to share it – Hunt Jul 30 at 14:57
  • Updated my answer – manjit5190 Jul 30 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.