Salesforce Lightning REST API Request - Null Reference Exception

Hello,

I’m attempting to call a Lightning API through the provided UiPath.Salesforce.Activities.LightningRequestApiRequest activity. I have the following configuration:

AcceptFormat: ANY
Method: POST
Resource: [Redacted]
Body: Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, Newtonsoft.Json.Formatting.None) where requestBody is a Dictionary<string, string> and I can confirm its content is correct.
BodyFormat: application/json
Headers: None
ResultPath: Not Defined
Result: Not Defined
SalesforceStatus: updateProgress
StatusCode: Not Defined

The activity exists within a Salesforce Application Scope. After getting a single record from a database, I am attempting to use an endpoint to update a status record for the item to “In Progress.”

Full exception details here, though it’s not particularly helpful as the NRE doesn’t describe which field it expects to be present:

System.NullReferenceException: Object reference not set to an instance of an object.
   at UiPath.Salesforce.ConnectionService.SalesforceConnectionService.InvokeRestApi(String lightningRestResource, String method, String acceptFormat, RestApiBody body, Dictionary`2 headers, String resultPath)
   at UiPath.Salesforce.Activities.LightningRestApiRequest.<>c__DisplayClass37_0.<SalesForceExecute>b__0(SalesforceTelemetryOperation operation)
   at UiPath.Salesforce.Telemetry.TelemetryServiceBase.Operation[T](String operationName, String activityId, Func`2 method)
   at UiPath.Salesforce.Activities.LightningRestApiRequest.SalesForceExecute(CodeActivityContext context)
   at UiPath.Salesforce.Activities.SalesforceActivityBase.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Am I missing some sort of setting here or is there a bug with the activity itself?

Edit: I’m using UiPath.Salesforce.Activities version 1.9.3

Are you passing dictionary or json to the api? Null reference been that the object created is of null value.

Hi Gaurav,

The body is being built using a dictionary. I serialize it into a json string before passing it into the Salesforce activity, which allows me to inspect that body string. When stepping through, I am able to see that the string is generated properly and it has the content I would expect to see.

Just test with GET method that whether you are able to get the result.

I ended up just replacing the Lightning REST Request activity with a pair of HTTP Client activities, one to authenticate manually and one to call the endpoint manually. These two work exactly as expected, even though the Lightning REST Request activity does not.

Quite weird. Can you share your xaml?