Sunteți pe pagina 1din 3

Configuring REST Adapter for Salesforce Upsert Operation

Configuring Rest Adapter connection for Salesforce application:

Pre-requisites:
Create a connected app in salesforce account with OAUTH enabled and get the respective
Consumer/Client Key and Consumer/Client Secret. Please note the app should have minimum
of below previlages,
1. Access your basic information (id, profile, email, address, phone)
2. Access and manage your data (api)
3. Perform requests on your behalf at any time (refresh_token, offline_access)
For more information in Connected apps for rest api please find the URL -
https://resources.docs.salesforce.com/sfdc/pdf/api_rest.pdf (Page - 6)
Creating connection:
1. In Connections page click on create and select REST adapter in the available options.
Provide a valid name and click create.
2. In Configure connectivity section,
a. Connection Type : REST API Base URL
b. Connection URL : https://{YOUR_SALESFORCE_URL}.salesforce.com/
Example : https://ap4.salesforce.com/
3. In Configure Security Section :
a. Authorization Token :
https://{login/test}.salesforce.com/services/oauth2/authorize?response_type=c
ode&client_id={YOUR_CLIENT_ID}&redirect_uri=https://{YOUR_OIC_CLOUD_Do
main}:443/icsapis/agent/oauth/callback
b. Access Token :
-X POST
'https://{login/test}.salesforce.com/services/oauth2/token?code=${auth_code}&
client_id={YOUR_CLIENT_ID}&client_secret={YOUR_CLIENT_SECRET}&redirect_u
ri=https://{YOUR_OIC_CLOUD_Domain}:443/icsapis/agent/oauth/callback&grant
_type=authorization_code'
c. Refresh Token :
-X POST
'https://{login/test}.salesforce.com/services/oauth2/token?refresh_token=${refr
esh_token}&client_id={YOUR_CLIENT_ID}&client_secret={YOUR_CLIENT_SECRET
}&grant_type=refresh_token'
Kindly note under Configure security the URLs will change as below,
• For authorization:
Production : https://login.salesforce.com/services/oauth2/authorize
Sandbox : https://test.salesforce.com/services/oauth2/authorize

• For token requests:


Production : https://login.salesforce.com/services/oauth2/token
Sandbox : https://test.salesforce.com/services/oauth2/token

• For revoking OAuth tokens:


Production : https://login.salesforce.com/services/oauth2/revoke
Sandbox : https://test.salesforce.com/services/oauth2/revoke

Configuring endpoint with Rest Adapter connection for Salesforce application to perform
Upsert/Patch Operation:

1. Drag and drop the configured REST Adapter connection on the to the target side or
Invoke side.
2. In Basic Info page,
a. Provide the endpoint name.
b. Resource URI.
Example for upsert operation would be
“/services/data/v43.0/sobjects/Account/Account_Ext_Id__c/{External_Id_Value}”
Note: In URI path “Account_Ext_Id__c” is a field defined as type “External Id” in
Salesforce and “External_Id_Value” is the parameter which we need to map in the
request mapper to pass the value dynamically at runtime.
c. Select action as “PATCH”.
d. Select checkboxes for configuring request and response payloads.
You can leave response payload if not required.

Click “Next” and continue.


3. In “Request parameters” page check the parameter name and its respective data type
which we defined in the URI Path and click “Next”.
4. In “Request” page select the feasible way to define the request payload and click
“Next”.
5. If you selected the checkbox related to response payload in Basic Info page then, in
“Response” page select the feasible way to define the response payload and click
“Next”.
6. Now check the summary page and click “Done”.
Note:
1. While Mapping Request payload for Upsert operation we need to map the incoming
external Id value to the URI parameter which we configured in the “Basic Info” page.
2. In Runtime the salesforce response is as follows,
Request type Sample Data Response Comments
Endpoint: HTTP - 201 Created
/services/data/v43.0/sobjects/Account
/Account_Ext_Id__c/12005 {
Create new "id" : "00190000029LGFDAA4", Operation executes
Account { "success" : true, successfully in Oracle
"Name" : "Test", "errors" : [ ] Integration Cloud.
"Phone" : "9090900001" }
}
Endpoint: HTTP - 204 No Content
/services/data/v43.0/sobjects/Account Operation performs
/Account_Ext_Id__c/12005 No response data successfully but Error will
Update be raised due to empty
Existing { response which fails at
Account "Name" : "Test", XSL Transformation in
"Phone" : "9090900001" Oracle Integration Cloud.
}
Endpoint: HTTP-400 Bad Request
/services/data/v43.0/sobjects/Account
/Account_Ext_Id__c/12005 [{
"message" : "Required fields Operation fails at
Business { are missing: [Name]", salesforce application
Error "Name" : "", "errorCode" : and raised API Invocation
"Phone" : "9090900001" "REQUIRED_FIELD_MISSING", error.
} "fields" : [ "Name" ]
}]

S-ar putea să vă placă și