bitrix icon indicating copy to clipboard operation
bitrix copied to clipboard

Adding a file to a custom field when creating a deal

Open SparTT opened this issue 2 years ago • 1 comments

I'm trying to add an image to a custom field when I create a deal, but I've been receiving the same HTTPError.

I'm trying to execute the code below:

const imgData = [{
  fileData: [ "test-st.png", "iVBORw0KGgoAAAANSUh..." ] // fileData[1] is a base64 str 
}]

let data = await bitrix.deals.create({
    fields: {
      TITLE: "ST-TEST",
      CATEGORY_ID: 18,
      UF_CRM_1659988440473: 4759,
      UF_CRM_1678981077892: imgData, 
    },
  }, {
    REGISTER_SONET_EVENT: 'Y'
})

The full error is:

{
    "name": "HTTPError",
    "timings": {
        "start": 1684867744230,
        "socket": 1684867744231,
        "lookup": 1684867744255,
        "connect": 1684867744410,
        "secureConnect": 1684867744568,
        "upload": 1684867744568,
        "response": 1684867744880,
        "end": 1684867744881,
        "phases": {
            "wait": 1,
            "dns": 24,
            "tcp": 155,
            "tls": 158,
            "request": 0,
            "firstByte": 312,
            "download": 1,
            "total": 651
        }
    }
}

What can I do to solve this?

SparTT avatar May 23 '23 20:05 SparTT

This is a long-standing issue with how we handle the requests to the Bitrix API. We are using GET requests and sending base64 encoded string will trigger 414 HTTP error. I will have to investigate if there anything we can do without changing too much code to make this work

mrhyde avatar May 26 '23 22:05 mrhyde