Visual Builder

Get Involved. Join the Conversation.


    Ankur Jain
    Not able to call REST API from VBCS which accepts attachment...
    Topic posted August 10, 2019 by Ankur JainBronze Trophy: 5,000+ Points, tagged REST, Web 
    33 Views, 2 Comments
    Not able to call REST API from VBCS which accepts attachment in request

    Hi Experts,

    I have created one REST API in Integration Cloud which takes attachment and payload in request body due to which request header type is multipart/mixed. This API is working fine from POSTMAN.

    Would like to call the REST API from VBCS page. This VBCS page should have one text box, file uploader and button. On button click, I would like to call the REST API.

    Can you guys help me to achieve this.





    • Kanchankumar Khedkar

      You will have to create input using JS. 


      PageModule.prototype.formdata = function(uploadfile, input1,input2){
            var formData = new FormData();
            formData.append('file', uploadfile,;
            formData.append('json', JSON.stringify({   "FileUploadRequest": {"Field1": input1,    "Field2": input2} }));
            return formData;

      Invoke this on Select button. 

      after that you In Invoke Rest you can you can map the output of JS to body . 

      • David Konecny

        In my app a definition of REST call for multipart form upload looks like this (in JSON source):

                "callRestEndpoint1": {
                  "module": "vb/action/builtin/restAction",
                  "parameters": {
                    "endpoint": "documentsApi1_2/postFilesData",
                    "contentType": "multipart/form-data",
                    "responseType": "application/json",
                    "body": {
                      "jsonInputParameters": "{{ '{ \"parentID\":\"' + $page.variables.folderId + '\"}' }}",
                      "primaryFile": "{{ $page.variables.uploadFile ? $page.variables.uploadFile.files[0] : {} }}"
                    "requestType": "form"