Salesforce Standard API - Content Version











up vote
1
down vote

favorite












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


























    up vote
    1
    down vote

    favorite












    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
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      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 3 hours ago









      Salvation

      455




      455






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          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























          • Thank you !!! :)
            – Salvation
            2 hours ago






          • 1




            The Composite resource would also work in this situation.
            – sfdcfox
            2 hours ago










          • @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
            51 mins ago










          • 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
            41 mins ago











          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',
          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








          up vote
          2
          down vote



          accepted










          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























          • Thank you !!! :)
            – Salvation
            2 hours ago






          • 1




            The Composite resource would also work in this situation.
            – sfdcfox
            2 hours ago










          • @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
            51 mins ago










          • 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
            41 mins ago















          up vote
          2
          down vote



          accepted










          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























          • Thank you !!! :)
            – Salvation
            2 hours ago






          • 1




            The Composite resource would also work in this situation.
            – sfdcfox
            2 hours ago










          • @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
            51 mins ago










          • 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
            41 mins ago













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          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 1 hour ago

























          answered 2 hours ago









          Ayub

          1,589515




          1,589515












          • Thank you !!! :)
            – Salvation
            2 hours ago






          • 1




            The Composite resource would also work in this situation.
            – sfdcfox
            2 hours ago










          • @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
            51 mins ago










          • 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
            41 mins ago


















          • Thank you !!! :)
            – Salvation
            2 hours ago






          • 1




            The Composite resource would also work in this situation.
            – sfdcfox
            2 hours ago










          • @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
            51 mins ago










          • 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
            41 mins ago
















          Thank you !!! :)
          – Salvation
          2 hours ago




          Thank you !!! :)
          – Salvation
          2 hours ago




          1




          1




          The Composite resource would also work in this situation.
          – sfdcfox
          2 hours ago




          The Composite resource would also work in this situation.
          – sfdcfox
          2 hours ago












          @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
          51 mins ago




          @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
          51 mins ago












          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
          41 mins ago




          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
          41 mins ago


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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

          Ellipse (mathématiques)

          Quarter-circle Tiles

          Mont Emei