Attachment not working for REST API call. We are not able to attach a file in Lead/Contact after record creation.
Is there any change in API. Are we passing correct key value pair
string base64String;
byte[] byteArray = System.IO.File.ReadAllBytes(mypath);
try
{
base64String = System.Convert.ToBase64String(byteArray, 0, byteArray.Length);
}
catch (System.ArgumentNullException)
{
System.Console.WriteLine("Binary data array is null.");
return;
}
string urlattachmen = string.Format("{0}setBinaryData?sessionId={1}&id={2}&fieldName =file&value=base64Strin&contentType="application/pdf"&value={5}", API_Method.Utils.GlobalURL, Globals.ThisAddIn.SessionID, id, file, base64String,"application/pdf ", "Profile.pdf");
System.Net.WebRequest reqs = System.Net.WebRequest.Create(urlattachmen);
//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();/
I am not aware of any bug here but let me check.
Also, could you tell me which Rollbase REST API are you using?
Reply by LaurentAlso, could you tell me which Rollbase REST API are you using?
Stop receiving emails on this subject.Flag this post as spam/abuse.
Reply by LaurentAlso, could you tell me which Rollbase REST API are you using?
Stop receiving emails on this subject.Flag this post as spam/abuse.
Flag this post as spam/abuse.
By "only see one" do you mean in the documentation or something else?
Reply by LaurentBy "only see one" do you mean in the documentation or something else?
Stop receiving emails on this subject.Flag this post as spam/abuse.
I was able to attach a document to a record using the REST API setDataField method (I however did it in Python not Java). However, you should make sure that the content of the LDF file is base 64-encoded. If that is the case, could you tell me what output are you getting?
Reply by LaurentI was able to attach a document to a record using the REST API setDataField method (I however did it in Python not Java). However, you should make sure that the content of the LDF file is base 64-encoded. If that is the case, could you tell me what output are you getting?
Stop receiving emails on this subject.Flag this post as spam/abuse.
Here's my code, written in Python 3.x. Note that you need to change the id and fieldName values in the URL:
import requests, sys, getpass, base64 import xml.etree.ElementTree as ET # Step 1: Login base_url = 'https://www.rollbase.com/rest/api/' login = input("Rollbase login: ") pw = getpass.getpass() url = base_url + 'login?loginName=' + login + '&password=' + pw r = requests.get(url) tree = ET.fromstring(r.content) session_id = tree[0].text print('Session ID: ' + session_id) # Step 2: call setDataField() url = base_url + 'setDataField?sessionId=' + session_id + \ '&id=967518&fieldName=myFieldName' + \ '&contentType=application/pdf&fileName=test.pdf' data = {'value': base64.b64encode(open('myfile.pdf', 'rb').read())} r = requests.post(url, data=data) print(r.content)
Reply by LaurentHere's my code, written in Python 3.x. Note that you need to change the id and fieldName values in the URL:
import requests, sys, getpass, base64 import xml.etree.ElementTree as ET # Step 1: Login base_url = 'https://www.rollbase.com/rest/api/' login = input("Rollbase login: ") pw = getpass.getpass() url = base_url + 'login?loginName=' + login + '&password=' + pw r = requests.get(url) tree = ET.fromstring(r.content) session_id = tree[0].text print('Session ID: ' + session_id) # Step 2: call setDataField() url = base_url + 'setDataField?sessionId=' + session_id + \ '&id=967518&fieldName=myFieldName&contentType=application/pdf&fileName=test.pdf' files = { 'value': base64.b64encode(open('myfile.pdf', 'rb').read()) } r = requests.post(url, data=files) print(r.content)Stop receiving emails on this subject.Flag this post as spam/abuse.
Good point. setBinaryField belongs to the REST API whereas setBinaryData belongs to the SOAP API. setDataField allows to update a field, whether binary or not.
If neither setBinaryField nor setDataField work for you using the REST API, I would need to know what error you are getting.