Forum Post: Sending attachment through Rest API call to Rollbase

  • Thread starter Thread starter anu31221@gmail.com
  • Start date Start date
Status
Not open for further replies.
A

anu31221@gmail.com

Guest
Not able to send attachment through Rest API call to Rollbase. Any one can share working code to send attachment Here is the code string mypath = Path.Combine(Path.GetTempPath(), attachment.DisplayName); //Store email attachment file attachment.SaveAsFile(mypath); FileInfo file = new FileInfo(attachment.DisplayName); string contenttye = "Applicaion/" + file.Extension.Replace(".",string.Empty); byte[] byteArray = System.IO.File.ReadAllBytes(mypath); string urlattachmen = string.Format("{0}create2?sessionId={1}&objName=$R_DOCS&file={2}&R2465433={3}&output=json", API_Method.Utils.GlobalURL, Globals.ThisAddIn.SessionID,mypath, o["id"].ToString()); System.Net.WebRequest reqs = System.Net.WebRequest.Create(urlattachmen); reqs.ContentType="Content-Type,"+ "application/x-www-form-urlencoded; charset=UTF-8"; reqs.Method = "Get"; reqs.ContentLength = byteArray.Length; //true means no proxy System.Net.WebResponse resps = reqs.GetResponse(); System.IO.StreamReader srs = new System.IO.StreamReader(resps.GetResponseStream()); string result = srs.ReadToEnd().Trim(); File.Delete(mypath);

Continue reading...
 
Status
Not open for further replies.
Back
Top