fe69b8c6b8 | ||
---|---|---|
src | ||
.gitignore | ||
LICENSE | ||
README.md |
README.md
Salesforce.CSharp.Metadata
A simple C# SDK for interacting with the Salesforce Metadata API.
Usage
Below you'll find some sample codes for using this library. You can also review the functional tests for cues on usage.
Login
var partnerClient = new PartnerClient();
var loginResult = await partnerClient.Login(Username, Password, ApiVersion);
Describe Metadata
var metadataClient = new MetadataClient(loginResult.MetadataServerUrl, loginResult.SessionId);
var describeMetadataResult = await metadataClient.DescribeMetadata();
List Metadata
var customObjects = await metadataClient.ListMetadata("CustomObject");
var apexClasses = await metadataClient.ListMetadata("ApexClass");
var auraDefinitionBundle = await metadataClient.ListMetadata("AuraDefinitionBundle");
Retrieve Metadata
var retrieveResult = await metadataClient.Retrieve();
Check Retrieve Metadata Status
var checkRetrieveStatusResult = await metadataClient.CheckRetrieveStatus(retrieveResult.Id);
if (checkRetrieveStatusResult.Status == "Succeeded")
{
var toBytes = Convert.FromBase64String(checkRetrieveStatusResult.ZipFile);
var fileName = checkRetrieveStatusResult.Id + ".zip";
var extractPath = checkRetrieveStatusResult.Id;
using (var fs = new FileStream(fileName, FileMode.Create))
{
fs.Write(toBytes, 0, toBytes.Length);
}
ZipFile.ExtractToDirectory(fileName, extractPath);
}