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)
}
Get Access Token:
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
No comments:
Post a Comment