Question

Hello, 

I added an object based on the File object, but I can't see the newly created object in the list of file storage locations. What could I be doing wrong?

Like 0

Like

3 comments

Hello,

For custom sections the files will be stored in SysFile object.

I need to add new columns that are specific to my section. Therefore, I have to create a new object. Is there a way to upload files into the newly created object?

Hello,

 

When a new attachment storage is created according to The File Management API. The file storage will be available in the list of objects the Freedom UI Attachments component works with.

Show all comments

We have an implementation of saving data in the "History" of Contacts, and we use the HttpWebRequest method like this POST. However, now every time we try to upload a file into the History email it returns this  Error: 'The remote server returned an error: (400) Incorrect Request.'.

private static bool TransferFile(Guid fileRecordId, string columnName, byte[] file) {
            log.Debug("[START] Transfer file");
            try {
                string requestUri = ServerUriUsr + "ActivityFileCollection(guid'" + fileRecordId.ToString() + "')/" + columnName;
                HttpWebRequest request = RequestHelper.BuildRequest(requestUri, HttpMethod.Put);
                request.Accept = "application/octet-stream,application/json;odata=verbose";
                request.ContentType = "multipart/form-data;boundary=+++++";
                // Recording the xml message to the request stream.
                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(file, 0, file.Length);
                }
                // Receiving a response from the service regarding the operation implementation result.
                using (WebResponse response = request.GetResponse())
                {
                    if (((HttpWebResponse)response).StatusCode == HttpStatusCode.Created)
                    {
                        // Processing the operation implementation result.
                        response.Close();
                        log.Debug("[END] Transfer file (Successful)");
                        return true;
                    }
                }
            }
            catch (WebException ex) {
                if (ex.Response is null)
                    log.Error($"TransferFile function error: {ex.Message}");
                else
                    log.Error($"TransferFile function error: {new StreamReader(ex.Response.GetResponseStream()).ReadToEnd()}");
                throw;
            }
            catch (Exception ex) {
                log.Error($"TransferFile function error: {ex.Message}");
                throw;
            }
 
            return false;
        }

The problem only occurs when I try to upload a .docx or .xlsx file

Like 0

Like

2 comments

Have you checked failed IIS requests logs and the applicaiton logs for more information on the invalid request? What was the result of the check?

Oleg Drobina,

I ended up doing more tests and the problem only occurs when it is a .docx and .xlsx type file.

When it is PDF or images it works normally without any problems.

Show all comments

Hello,

I am working on uploading a large amount of xlsx files into my system using Creatio's Data Import wizard. I am currently uploading them one at a time but I'm wondering if there would be any negative effect to uploading more than one file at a time. 

The wizard is creating Contact records and there isn't any overlap between the different xlsx files so I was wondering if I could run two imports at the same time. 

Like 0

Like

1 comments

Dear Kevin, 

It is highly not recommended to do more than one import at once. It may vastly slow down the system to the point that the system may even become inaccessible. 

Show all comments

Hi Team

I created a Node.js script to upload attachments using FileApiService.

Here is my script:

var axios = require('axios');

var fs = require('fs');

establish_connection();

 

async function establish_connection()

{

        axios.post('https://company_name.bpmonline.com/ServiceModel/AuthService.svc/Login',

        {

            "UserName":"xxxxxxx",

            "UserPassword":"xxxxxxxxxxx"

            

        }).then (function (response){

            console.log('Imported credentials cookie from BPM Online!')

            c=response.headers['set-cookie']

            var bpm_loader=c[0]

            bpm_loader = bpm_loader.replace('BPMLOADER=','')

            bpm_loader=bpm_loader.split(';')[0]

            var aspx_auth=c[1]

            aspx_auth = aspx_auth.replace('.ASPXAUTH=','')

            aspx_auth=aspx_auth.split(';')[0]

            var bpm_csrf=c[2]

            bpm_csrf = bpm_csrf.replace('BPMCSRF=','')

            bpm_csrf=bpm_csrf.split(';')[0]

            var user_name=c[3]

            user_name = user_name.replace('UserName=','')

            user_name=user_name.split(';')[0]

            var auth = 'BPMLOADER='+bpm_loader+'; .ASPXAUTH='+aspx_auth+'; BPMCSRF='+bpm_csrf+'; UserName='+user_name+';';

            console.log('Authentication Successful!')

            upload_attachments(auth,bpm_csrf)

        }).catch(error => {

            console.log(error)

        })

}

async function upload_attachments(auth,bpm_csrf) {

  let myPdf = fs.readFileSync("./file_name.pdf");

  let myData = myPdf.toString("base64");

 

  let myBody = {

    Name: "test.pdf",

    Data: myData,

    TypeId: '529bc2f8-0ee0-df11-971b-001d60e938c6',//This indicates that the type of the attachment is file

    Version: "1",

    Usr_reference_column_id: 'xxxxxguid_of_the_record_xxxxxxxx'

  };

 

  let options = {

    method: "POST",

    url: 'https://company_name.bpmonline.com/0/rest/FileApiService/Upload',

    headers: {

        "fileapi14998570381414":"",

      "cache-control": "no-cache",

      "Accept-Encoding": "gzip, deflate",

      "Cache-Control": "no-cache",

      Accept: "*/*",

      "Content-Type": "application/json;odata=verbose",

      Cookie:auth,

      BPMCSRF:bpm_csrf,

      "entitySchemaName":"Usr_id_of_the_file_section"

    },

    body: myBody,

    json: true

  };

 

  request(options, function(error, response, body) {

    if(!error)

    {

        console.log('Success!')

        console.log(response)

    }

    else

    {

        console.log('Failed!')

        console.log(error)

    }

  });

}

 

References: 

1. https://community.bpmonline.com/questions/sending-blob-file-node

2. https://community.bpmonline.com/questions/upload-files-case

3. https://community.bpmonline.com/questions/how-upload-attachments-odata

4. https://community.terrasoft.ru/questions/realizacia-peredaci-pdf-dokumenta-po-protokolu-odata-s-ispolzovaniem-http-zaprosov

5. https://community.terrasoft.ru/questions/fileapiservice-zagruzka-dokumenta-v-faily-i-primecania-crm-sistemy

 

I am able to establish connection (Authorization is successful) and getting SUCCESS for the attachment. But in the response, I am receiving 'Request Error'.

 

Questions:

1. Is my URL correct?

2. Is the way I specified file section name correct?

3. Do I need to add/delete/change my request body?

4. Do I need to create a MODULE in ADVANCED SETTINGS?

 

NOTE: I am using BPM'Online Studio.

Like 0

Like

1 comments

It's hard to say how it should be done on Node.js. However, there is an easy way to find if your request is correct. Please install "telerik fiddler" and catch the request that you send to bpm'online. For example, send file.jpg. Then open bpm'online and add the same file for example to a contact. Catch the request with fiddler too. Then compare those two requests. Your task is to create a functionality that will send exactly the same request. 

If you need an example on JS, please put a break point into the "upload" method in the ConfigurationFileApi module (in a browser) and add a file to a contact. You'll see how bpm'online generates the request. Please try to do the same on Node.js. 

Show all comments

Hi,

On case landing page there is file upload field, that file need to be copy to CRM with other normal fields values.

 

Any help will be highly appreciable.

 

Regards

Like 0

Like

1 comments

Unfortunately, landing pages don't allow uploading attachments. Please find more information about uploading attachments in the answer by the link below.

https://community.bpmonline.com/questions/attachments-and-notes-using-dataservices

Show all comments