How to POST a document in binary format?

Hello World,

I am looking for a way to make a Rest API call to post a document.

The document need to be converted in binary.

Best

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to rameshg647

    Hi @rameshg647 this can happen in following cases:

    1. When conversion of the document to Base64 didn't happen properly

    2. While converting Base64 back to document in SharePoint: there might be something wrong they might have coded in SharePoint

    Alternate option: Why don't you give a try to http file upload smart service which is OOTB. This accepts headers , endpoint , basic authentication (if any) and the document. Here authentication can be done using integration object and the response header ( key and value) you can pass to this smart Service , that should do your job.

    And in fact, if Base64 is not only your requirement, then HTTP file upload smart service is the best option for you, because it stream the document in binary instead of converting and storing the entire document in memory (causes performance issues) which is being done by Base64 smart service.

    Hence If the target system is not expecting the document in Base64 format then I recommend you better go for http file upload smart Service.

    Hope this will help

  • PLease find my inline answers below:

    1. When conversion of the document to Base64 didn't happen properly: [The conversion was good, we were able to decode it back to appropriate file using online tools.]

    2. While converting Base64 back to document in SharePoint: there might be something wrong they might have coded in SharePoint[The conversion was good, we were able to decode it back to appropriate file using online tools.]

    Alternate option: Why don't you give a try to http file upload smart service which is OOTB. This accepts headers , endpoint , basic authentication (if any) and the document. Here authentication can be done using integration object and the response header ( key and value) you can pass to this smart Service , that should do your job.[We cannot use http file upload smart service as it only supports basic authentication.]

    And in fact, if Base64 is not only your requirement, then HTTP file upload smart service is the best option for you, because it stream the document in binary instead of converting and storing the entire document in memory (causes performance issues) which is being done by Base64 smart service.[We cannot use http file upload smart service as it only supports basic authentication. We can only use Integration object with Oauth authentication.]
    Please let us know if there is any thing we are missing.
  • 0
    Certified Lead Developer
    in reply to rameshg647

     You need to leave basic authentication input parameter empty, you just need to pass the headers, and in order to get the headers, authentication is required which will be done by Integration Object. Below are the steps to achieve this.

    1. Create an Integration Object which is responsible to perform the Authentication
    2. Call this integration Object in process model and get it's response, parse it
    3. Set the required headers Keys (let's say, OAuth, Cookie etc..) into HTTP File Upload Smart Service Headers Key and it's header values will be your parsed response (which you have got after authentication using Integration Object/or by any other authentication approach)
    4. set the endpoint of file upload

    And you are done, you will be able to upload the document to Sharepoint/any other system successfully.

    NOTE:
    1. HTTP File upload is a generic smart service which will work for most of the services, if we are able to provide the proper header details about the target system

    2. This is the reason, basic authentication input parameter is marked as not required in this Smart Service.

    Hope this will help.