Use HTTP Callout PUT Method (use POST to get ID and then use for PUT operation) in flow #inSalesforce

Use HTTP Callout PUT Method (use POST to get ID and then use for PUT operation) in flow #inSalesforce


Create a Named Credential, External Credential and Permission Set


External Credential: Http Callout External Credential (same name), Custom auth


Create: Principal

Parameter Name: Http Principal, sequence number 1 and identity Type - Named Principal


Create Permission Set: Http Callout Permission Set


Add External Cred. Principal Access to the Permission Set (Select to Enabled External Cred. Principals) | Save


Add the permission set to User


Named Credential:

Http Named Credential (same name)

URL: https://api.restful-api.dev

External Cred: Select the one you created

No header required


POST Method - To get Id in the Response to be used in Put


Create flow: screen


Action: Create HTTP Callout

HttpCalloutService

Select the Named Credential you created


Configure Invocable Action:

Http Post Action (Label)

Method: POST

URL Path: /objects

Sample Request and Response: Add from the website as in visual | Review | Done


Details on ACtion:

Http Post Action Element

Value: New resource | PostActionVariable | Done


Assignment:

Assign values to Post variable

PostActionVariable.Data.Name equals Apple MaxBook Pro 16

PostActionVariable.Data.Model equals Intel Core i9

PostActionVariable.Data.HardDisk equals 1 TB

PostActionVariable.Data.Price equals 1849.99

PostActionVariable.Data.Year equals 2019


Done


Save the flow and debug



For PUT: (to update data using the id fetched from post)


Append another Action:

Add Action Element:

Name: HttpPutExternalService

Use the same Named Credential


Configure Invocable Action:

Http Put Action, PUT Method

URL Path:

/object/{postId} [postId- contains the id of the response]


the datatype of Id String


Sample Request and Response: Add from the website as in 

visual | Review | Done


Details on ACtion:

Http Put Action Element

Value: Select ouputfrompostaction.Id


Request body:

value: Create an apex-defined variable | ActionPutBodyVariable

Done



Assignment:

Assign values to ActionPutBodyVariable

ActionPutBodyVariable.Data.Name equals Apple MacBook Pro 17

ActionPutBodyVariable.Data.Model equals Intel Core i9

ActionPutBodyVariable.Data.HardDisk equals 2 TB

ActionPutBodyVariable.Data.Price equals 2049.99

ActionPutBodyVariable.Data.Year equals 2020


Done


Save and debug

Comments