2

I am using jsforce for fetching ContentVersionData from a Node app. My query is SELECT VersionData FROM ContentVersion but instead of fetching the base64 value in VersionData field i m getting an url.

Let me know how to fetch base64 value of multiple ContentVersion in one go.

=========================Connection Code ================================

    let username = req.body.username;
    let password = req.body.password;
    const conn = new jsforce.Connection({
        loginUrl : 'https://test.salesforce.com/'
    });
    await conn.login(username,password);
   req.conn = conn;

=======================================================================

==================Query Code ======================================

let conventVersion = await sfConnection.query('SELECT VersionData FROM ContentVersion');
    conventVersion.records.forEach(ele=> {
        console.log(ele.VersionData);

===========================================================================

=================Output Generated ========================

/services/data/v42.0/sobjects/ContentVersion/0685D000000YcdCQAS/VersionData /services/data/v42.0/sobjects/ContentVersion/0685D000000YcdbQAC/VersionData /services/data/v42.0/sobjects/ContentVersion/0685D000000Yd18QAC/VersionData /services/data/v42.0/sobjects/ContentVersion/0685D000000YdIYQA0/VersionData /services/data/v42.0/sobjects/ContentVersion/0685D000000YfhzQAC/VersionData

Thanks

4
  • It's worth looking at the data model diagram of all the Contact Objects here and the ContentVersion tech docs Jan 15, 2020 at 10:48
  • Hi Brian , Thanks for quick response . Looked at both the link you shared but not able figure how to do the same. Can you help me out ?
    – AjSyles
    Jan 15, 2020 at 10:59
  • 1
    Can you please provide a code of your connection query and the returned results? Jan 15, 2020 at 11:20
  • Hi Oleh updated the post with code!
    – AjSyles
    Jan 15, 2020 at 14:31

1 Answer 1

2

The reason for JSForce responding back with the URLs is because JSForce is using the REST API and that won't return back the Base64 content. Salesforce's SOAP API will however though when you issue a query with a Base64 field.

4
  • Thanks a lot Bryan it worked!
    – AjSyles
    Jan 16, 2020 at 7:25
  • Bryan, Can you let me know how put Set of Ids in query string in SOAP API when we have large set of ids? Stuck on ContentDocumentLink
    – AjSyles
    Jan 16, 2020 at 8:24
  • @AjSyles I would suggest looking at using the retrieve() SOAP API call to perform what you are looking for developer.salesforce.com/docs/atlas.en-us.api.meta/api/… Jan 16, 2020 at 15:48
  • Thanks a lot ! You are a saviour!
    – AjSyles
    Jan 16, 2020 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .