Thursday, July 28, 2022

Send Document to Salesforce using API; Postman; UiPath RPA

Postman Collection


PO Environment:






HTTP Request POST
OAUTH:

https://app.sandbox.my.salesforce.com //instance url

//Add below Parameters to HTTP Request

username

password

grant_type

client_id

client_secret


Get Response content to json file. Deserialize to get access_token


ADD FILE: HTTP Request POST

//Convert the document to Bytes[] bytes

https://app.sandbox.my.salesforce.com/services/data/v53.0/sobjects/ContentVersion

//Add below json to body of HTTP Request

{"PathOnClient": "C:\Users\Public\Documents\test.pdf",

  "Title": "0.jpg", //docName

  "VersionData":Convert.ToBase64String(bytes)

}

Pass Header: Authorization String access_token






Http Request GET

GET ContentDocumentId

https://app.sandbox.my.salesforce.com/services/data/v53.0/query/?q=SELECT ContentDocumentId FROM ContentVersion where Title = '+"0.jpg"+'

Pass Header: Authorization String access_token



HTTP Request POST

Assign the File to Case:

https://app.sandbox.my.salesforce.com/services/data/v53.0/sobjects/ContentDocumentLink

Pass below in body


{ "ContentDocumentId":"The ID from GET function",

"LinkedEntityId":"CASE ID",

"ShareType":"V"

}

Pass Header: Authorization String access_token



Helpful video:

https://youtu.be/ONpe-O2eMIM






No comments: