I am using Python/Beatbox to access Salesforce cases.
service = beatbox.PythonClient() # instantiate the object
service.login(...) # login using your sf credentials
query_result = service.query("SELECT Id, AccountId, CaseNumber FROM Case WHERE Id='xyz' ")
I'm interested in a specific case:
print query_result[0].Id
Get attachments...
att_result = service.query("SELECT Id, ContentType, Name FROM Attachment WHERE ParentId= '" + str(query_result[0].Id) + "'")
So far the results are good. Now I want to download the files uploaded to the case. What should be my query? I tried following and its always empty..But Im sure the case has files as well as attachments..
doc_result = service.query("SELECT Id, ContentDocumentId, Title FROM AttachedContentDocument WHERE Id= '" + str(query_result[0].Id) + "'")
I also tried the document object and still no success. I appreciate your help.
Refer this for session_id: https://github.com/simple-salesforce/simple-salesforce
You can get not more than one Attachment by one request in any Salesforce API. To be sure that you don't an attachment, get the Attachment.Id first, then get the body by a loop
A) SOAP API (Beatbox): Get the Attachment as a normal long base64encoded field.
The query should expect one row because the output is restricted to one row if the "Body" field is present.
B) If REST API is used (simple-salesforce package) with the same queries, the value of
Body
orVersionData
fields is a URL of the form'/services/data/v40.0/sobjects/Attachment/<object_id>/Body'
which can be downloaded by GET request.C) Fetch Salesforce Attachment content with django-salesforce
Objects useful for Binary Large OBjects are Attachment, Document and ContentVersion. These useful queries allow to get a binary large object (Attachment or Document) as a normal long field by SOAP API (Beatbox). The
ContentVersion
object allows to store more versions of the same data.Attachment
has a parent object.Document
is without any parent object. Useful queries: (read restrictions by API above)