function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anupama AndripalliAnupama Andripalli 

Retrieving attachment using .NET


I am trying to do the same to retreive pdf documents using c#.Here is my code and it not working as the body is not the encoded attachment string but something like "/services/data/v28.0/sobjects/Attachment/00Pi0000001UMXa/Body".
            var auth = new AuthenticationClient();
            var url = "https://test.salesforce.com/services/oauth2/token";
            await auth.UsernamePasswordAsync(CustomerKey, CustomerSecret, Username, Password, url);
            var client = new ForceClient(auth.InstanceUrl, auth.AccessToken, auth.ApiVersion);
                const string fName = "leaseattachment";
                const string qry = "select Name, Body, ContentType from Attachment where ParentId='a0b1100000K0TkKAAV'";
                var fields = await client.QueryAsync<LeaseAttachment>(qry);
                var fileContents = fields.records.FirstOrDefault<LeaseAttachment>();
                byte[] bName = Convert.FromBase64String(fileContents.Body);
               StreamWriter os = new StreamWriter("C:\\Users\\test\\Downloads" + "\\" + fName);
               os.Write(bName);
                os.Close();
Can someone help me with it?
Thanks,
Anu
RamuRamu (Salesforce Developers) 
The below post might help

http://stackoverflow.com/questions/13870089/how-to-display-salesforce-attachments-in-asp-net-website-to-download