Salesforce Standard API - Content Version












1















I'm trying to send an array of content versions via the Standard API that Salesforce suggests :



Using POST method to :



https://SandboxName.my.salesforce.com/services/data/v43.0/sobjects/ContentVersion



[
{
"VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
"PathOnClient":"Array1.jpg",
"Description":"Array1",
"Document_Type__c":"1"

},

{
"VersionData":"/9j/4AAQSkZJRgh25==",
"PathOnClient":"Array2.jpg",
"Description":"ARRAy2",
"Document_Type__c":"1"
}
]


With one file - Its working, but when I change it to array and add another file - Its throw me this error :



**[
{
"message": "Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row",
"errorCode": "INVALID_FIELD"
}
]**


My questions are:




  1. What the problem here???


  2. I'm sending the request ok? and if I do - this is legal to do? (send it as an array).


  3. There are limitations that I need to be aware of using an array?



Thank you.










share|improve this question



























    1















    I'm trying to send an array of content versions via the Standard API that Salesforce suggests :



    Using POST method to :



    https://SandboxName.my.salesforce.com/services/data/v43.0/sobjects/ContentVersion



    [
    {
    "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
    "PathOnClient":"Array1.jpg",
    "Description":"Array1",
    "Document_Type__c":"1"

    },

    {
    "VersionData":"/9j/4AAQSkZJRgh25==",
    "PathOnClient":"Array2.jpg",
    "Description":"ARRAy2",
    "Document_Type__c":"1"
    }
    ]


    With one file - Its working, but when I change it to array and add another file - Its throw me this error :



    **[
    {
    "message": "Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row",
    "errorCode": "INVALID_FIELD"
    }
    ]**


    My questions are:




    1. What the problem here???


    2. I'm sending the request ok? and if I do - this is legal to do? (send it as an array).


    3. There are limitations that I need to be aware of using an array?



    Thank you.










    share|improve this question

























      1












      1








      1








      I'm trying to send an array of content versions via the Standard API that Salesforce suggests :



      Using POST method to :



      https://SandboxName.my.salesforce.com/services/data/v43.0/sobjects/ContentVersion



      [
      {
      "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
      "PathOnClient":"Array1.jpg",
      "Description":"Array1",
      "Document_Type__c":"1"

      },

      {
      "VersionData":"/9j/4AAQSkZJRgh25==",
      "PathOnClient":"Array2.jpg",
      "Description":"ARRAy2",
      "Document_Type__c":"1"
      }
      ]


      With one file - Its working, but when I change it to array and add another file - Its throw me this error :



      **[
      {
      "message": "Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row",
      "errorCode": "INVALID_FIELD"
      }
      ]**


      My questions are:




      1. What the problem here???


      2. I'm sending the request ok? and if I do - this is legal to do? (send it as an array).


      3. There are limitations that I need to be aware of using an array?



      Thank you.










      share|improve this question














      I'm trying to send an array of content versions via the Standard API that Salesforce suggests :



      Using POST method to :



      https://SandboxName.my.salesforce.com/services/data/v43.0/sobjects/ContentVersion



      [
      {
      "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
      "PathOnClient":"Array1.jpg",
      "Description":"Array1",
      "Document_Type__c":"1"

      },

      {
      "VersionData":"/9j/4AAQSkZJRgh25==",
      "PathOnClient":"Array2.jpg",
      "Description":"ARRAy2",
      "Document_Type__c":"1"
      }
      ]


      With one file - Its working, but when I change it to array and add another file - Its throw me this error :



      **[
      {
      "message": "Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row",
      "errorCode": "INVALID_FIELD"
      }
      ]**


      My questions are:




      1. What the problem here???


      2. I'm sending the request ok? and if I do - this is legal to do? (send it as an array).


      3. There are limitations that I need to be aware of using an array?



      Thank you.







      api governorlimits contentversion






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 17 '18 at 10:03









      SalvationSalvation

      676




      676






















          1 Answer
          1






          active

          oldest

          votes


















          2














          The way you are following can insert only one record. In order to create record in bulk using REST API, you need to use Composite Tree resource- Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type.



          So endpoint would be:
          https://SandboxName.my.salesforce.com/services/data/v43.0/composite/tree/ContentVersion



          Request Body:



          {"records" :[
          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref1"},
          "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
          "PathOnClient":"Array1.jpg",
          "Description":"Array1"
          },

          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref2"},
          "VersionData":"/9j/4AAQSkZJRgh25==",
          "PathOnClient":"Array2.jpg",
          "Description":"ARRAy2"
          }
          ]
          }


          P.S:
          In each row you would need to pass a reference id for each record as shown above.



          SOURCE ARTICLE: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm






          share|improve this answer





















          • 1





            The Composite resource would also work in this situation.

            – sfdcfox
            Dec 17 '18 at 10:59











          • @Ayub Is there any Limitation (I guess there are) on the size of the sum of all the contentVersions that I created? What is the Max size that I can handle with? Thnkas

            – Salvation
            Dec 17 '18 at 12:11











          • You cannot exceed the payload limit...I'm not sure how much it is 3mb or 6mb but it's fact there is limit and you need to take care of that....especially while uploading files via api...

            – Ayub
            Dec 17 '18 at 12:21











          • @Ayub In SF docs - They wrote that I can upload a file up to 2 GB (including headers) when uploaded via REST API - help.salesforce.com/… What am I missing here?? Many Thanks for you help

            – Salvation
            Dec 17 '18 at 14:45











          • It's when you are using salesforce user interface....if you are using api then regardless what you are uploading, api limits will be counted against...

            – Ayub
            Dec 17 '18 at 15:55











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "459"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f243826%2fsalesforce-standard-api-content-version%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          The way you are following can insert only one record. In order to create record in bulk using REST API, you need to use Composite Tree resource- Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type.



          So endpoint would be:
          https://SandboxName.my.salesforce.com/services/data/v43.0/composite/tree/ContentVersion



          Request Body:



          {"records" :[
          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref1"},
          "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
          "PathOnClient":"Array1.jpg",
          "Description":"Array1"
          },

          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref2"},
          "VersionData":"/9j/4AAQSkZJRgh25==",
          "PathOnClient":"Array2.jpg",
          "Description":"ARRAy2"
          }
          ]
          }


          P.S:
          In each row you would need to pass a reference id for each record as shown above.



          SOURCE ARTICLE: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm






          share|improve this answer





















          • 1





            The Composite resource would also work in this situation.

            – sfdcfox
            Dec 17 '18 at 10:59











          • @Ayub Is there any Limitation (I guess there are) on the size of the sum of all the contentVersions that I created? What is the Max size that I can handle with? Thnkas

            – Salvation
            Dec 17 '18 at 12:11











          • You cannot exceed the payload limit...I'm not sure how much it is 3mb or 6mb but it's fact there is limit and you need to take care of that....especially while uploading files via api...

            – Ayub
            Dec 17 '18 at 12:21











          • @Ayub In SF docs - They wrote that I can upload a file up to 2 GB (including headers) when uploaded via REST API - help.salesforce.com/… What am I missing here?? Many Thanks for you help

            – Salvation
            Dec 17 '18 at 14:45











          • It's when you are using salesforce user interface....if you are using api then regardless what you are uploading, api limits will be counted against...

            – Ayub
            Dec 17 '18 at 15:55
















          2














          The way you are following can insert only one record. In order to create record in bulk using REST API, you need to use Composite Tree resource- Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type.



          So endpoint would be:
          https://SandboxName.my.salesforce.com/services/data/v43.0/composite/tree/ContentVersion



          Request Body:



          {"records" :[
          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref1"},
          "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
          "PathOnClient":"Array1.jpg",
          "Description":"Array1"
          },

          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref2"},
          "VersionData":"/9j/4AAQSkZJRgh25==",
          "PathOnClient":"Array2.jpg",
          "Description":"ARRAy2"
          }
          ]
          }


          P.S:
          In each row you would need to pass a reference id for each record as shown above.



          SOURCE ARTICLE: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm






          share|improve this answer





















          • 1





            The Composite resource would also work in this situation.

            – sfdcfox
            Dec 17 '18 at 10:59











          • @Ayub Is there any Limitation (I guess there are) on the size of the sum of all the contentVersions that I created? What is the Max size that I can handle with? Thnkas

            – Salvation
            Dec 17 '18 at 12:11











          • You cannot exceed the payload limit...I'm not sure how much it is 3mb or 6mb but it's fact there is limit and you need to take care of that....especially while uploading files via api...

            – Ayub
            Dec 17 '18 at 12:21











          • @Ayub In SF docs - They wrote that I can upload a file up to 2 GB (including headers) when uploaded via REST API - help.salesforce.com/… What am I missing here?? Many Thanks for you help

            – Salvation
            Dec 17 '18 at 14:45











          • It's when you are using salesforce user interface....if you are using api then regardless what you are uploading, api limits will be counted against...

            – Ayub
            Dec 17 '18 at 15:55














          2












          2








          2







          The way you are following can insert only one record. In order to create record in bulk using REST API, you need to use Composite Tree resource- Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type.



          So endpoint would be:
          https://SandboxName.my.salesforce.com/services/data/v43.0/composite/tree/ContentVersion



          Request Body:



          {"records" :[
          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref1"},
          "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
          "PathOnClient":"Array1.jpg",
          "Description":"Array1"
          },

          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref2"},
          "VersionData":"/9j/4AAQSkZJRgh25==",
          "PathOnClient":"Array2.jpg",
          "Description":"ARRAy2"
          }
          ]
          }


          P.S:
          In each row you would need to pass a reference id for each record as shown above.



          SOURCE ARTICLE: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm






          share|improve this answer















          The way you are following can insert only one record. In order to create record in bulk using REST API, you need to use Composite Tree resource- Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type.



          So endpoint would be:
          https://SandboxName.my.salesforce.com/services/data/v43.0/composite/tree/ContentVersion



          Request Body:



          {"records" :[
          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref1"},
          "VersionData":"/9j/4AAQSkZJRgABAQEAYABADn/2Q==",
          "PathOnClient":"Array1.jpg",
          "Description":"Array1"
          },

          {
          "attributes" : {"type" : "ContentVersion", "referenceId" : "ref2"},
          "VersionData":"/9j/4AAQSkZJRgh25==",
          "PathOnClient":"Array2.jpg",
          "Description":"ARRAy2"
          }
          ]
          }


          P.S:
          In each row you would need to pass a reference id for each record as shown above.



          SOURCE ARTICLE: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 17 '18 at 11:13

























          answered Dec 17 '18 at 10:22









          AyubAyub

          1,747615




          1,747615








          • 1





            The Composite resource would also work in this situation.

            – sfdcfox
            Dec 17 '18 at 10:59











          • @Ayub Is there any Limitation (I guess there are) on the size of the sum of all the contentVersions that I created? What is the Max size that I can handle with? Thnkas

            – Salvation
            Dec 17 '18 at 12:11











          • You cannot exceed the payload limit...I'm not sure how much it is 3mb or 6mb but it's fact there is limit and you need to take care of that....especially while uploading files via api...

            – Ayub
            Dec 17 '18 at 12:21











          • @Ayub In SF docs - They wrote that I can upload a file up to 2 GB (including headers) when uploaded via REST API - help.salesforce.com/… What am I missing here?? Many Thanks for you help

            – Salvation
            Dec 17 '18 at 14:45











          • It's when you are using salesforce user interface....if you are using api then regardless what you are uploading, api limits will be counted against...

            – Ayub
            Dec 17 '18 at 15:55














          • 1





            The Composite resource would also work in this situation.

            – sfdcfox
            Dec 17 '18 at 10:59











          • @Ayub Is there any Limitation (I guess there are) on the size of the sum of all the contentVersions that I created? What is the Max size that I can handle with? Thnkas

            – Salvation
            Dec 17 '18 at 12:11











          • You cannot exceed the payload limit...I'm not sure how much it is 3mb or 6mb but it's fact there is limit and you need to take care of that....especially while uploading files via api...

            – Ayub
            Dec 17 '18 at 12:21











          • @Ayub In SF docs - They wrote that I can upload a file up to 2 GB (including headers) when uploaded via REST API - help.salesforce.com/… What am I missing here?? Many Thanks for you help

            – Salvation
            Dec 17 '18 at 14:45











          • It's when you are using salesforce user interface....if you are using api then regardless what you are uploading, api limits will be counted against...

            – Ayub
            Dec 17 '18 at 15:55








          1




          1





          The Composite resource would also work in this situation.

          – sfdcfox
          Dec 17 '18 at 10:59





          The Composite resource would also work in this situation.

          – sfdcfox
          Dec 17 '18 at 10:59













          @Ayub Is there any Limitation (I guess there are) on the size of the sum of all the contentVersions that I created? What is the Max size that I can handle with? Thnkas

          – Salvation
          Dec 17 '18 at 12:11





          @Ayub Is there any Limitation (I guess there are) on the size of the sum of all the contentVersions that I created? What is the Max size that I can handle with? Thnkas

          – Salvation
          Dec 17 '18 at 12:11













          You cannot exceed the payload limit...I'm not sure how much it is 3mb or 6mb but it's fact there is limit and you need to take care of that....especially while uploading files via api...

          – Ayub
          Dec 17 '18 at 12:21





          You cannot exceed the payload limit...I'm not sure how much it is 3mb or 6mb but it's fact there is limit and you need to take care of that....especially while uploading files via api...

          – Ayub
          Dec 17 '18 at 12:21













          @Ayub In SF docs - They wrote that I can upload a file up to 2 GB (including headers) when uploaded via REST API - help.salesforce.com/… What am I missing here?? Many Thanks for you help

          – Salvation
          Dec 17 '18 at 14:45





          @Ayub In SF docs - They wrote that I can upload a file up to 2 GB (including headers) when uploaded via REST API - help.salesforce.com/… What am I missing here?? Many Thanks for you help

          – Salvation
          Dec 17 '18 at 14:45













          It's when you are using salesforce user interface....if you are using api then regardless what you are uploading, api limits will be counted against...

          – Ayub
          Dec 17 '18 at 15:55





          It's when you are using salesforce user interface....if you are using api then regardless what you are uploading, api limits will be counted against...

          – Ayub
          Dec 17 '18 at 15:55


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f243826%2fsalesforce-standard-api-content-version%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Plaza Victoria

          Puebla de Zaragoza

          Musa