You need to sign in to do that
Don't have an account?

How to decode attachement body from base64 while using Async process Salesforce to .Net
HI All,
I am getting some issue my integration process, My senario is We are fetching the attachments from Salesforce with the help of Asynchronous process (Rest) api and adding all the files to .Dll file. But its Showing Error for Body fied Like 'Base64 format not supported'. How can we decode this Body content and how to add to dll file .
Please help Us.
Thanks
I am getting some issue my integration process, My senario is We are fetching the attachments from Salesforce with the help of Asynchronous process (Rest) api and adding all the files to .Dll file. But its Showing Error for Body fied Like 'Base64 format not supported'. How can we decode this Body content and how to add to dll file .
Please help Us.
Thanks
The API sends and receives the binary file attachment data encoded as a base64Binary data type. Prior to creating a record, client applications must encode the binary attachment data as base64. Upon receiving a response, client applications must decode the base64 data to binary (this conversion is usually handled for you by the SOAP client).
The difficult part is uploading an attachment to match Salesforce's specific multipart/form-data template. Without going into the exhausing details, the only I found to do this was to manually build the HTTP request body, and put the entire body in an ArrayBuffer, which the browser will not UTF-8 encode. Can you please try the below link and it should help you
http://salesforce.stackexchange.com/questions/56899/salesforce-isnt-handling-base64-encoded-attachments-uploaded-via-rest-api
Best Regards
Naga Kiran
Here we are not Uploading the attachments into salesforce . the req is fetching all the attachments and adding it to .Dll Using Async process (Rest). In Dotnet Environment.
Can u plz give your Suggetions. plese See the code and Guide me.
public partial class Attachments
{
private byte[] bodyField;
public string name { get; set; }
public string ContentType { get; set; }
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary", IsNullable = true, Order = 0)]
public byte[] Body // here the error is coming.
{
get
{
return this.bodyField;
}
set
{
this.bodyField = value;
}
}
}
public static class OpportunityServices
{
private static async Task<IEnumerable<Opportunities>> GenerateDealFromSalesforce()
{
var auth = new AuthenticationClient();
try
{
await auth.UsernamePasswordAsync("consumerkey","consumersecret","Username","Password", "https://test.salesforce.com/services/oauth2/token");
}
catch (Exception ex)
{
throw ex;
}
var client = new ForceClient(auth.InstanceUrl, auth.AccessToken, auth.ApiVersion);
string attachments = "SELECT Name, Body, ContentType FROM Attachment WHERE ParentId = 'ParentRecID'";
var att = await client.QueryAsync<Attachments>(attachments);
return null;
}
}