Hi Community,

I am trying to make a request from Creatio to the HTTP REST API Endpoints. |Where File should be added to the API request. 

Is there any way to work with the File type request Parameter in Rest API from Creatio? If yes, please suggest to me how I can achieve this.

 

An example of an API call from Postman is something like as per below :

 

Like 0

Like

3 comments

Hi Patrik,

 

To successfully upload an image you need to make sure that "WebDav publishing" feature is disabled in Windows features of the IIS server (can be found at "World wide web services" -> "Common HTTP Features" -> "WebDAVPublishing"):

Once done you need to perform the following steps:

 

1) Create a POST request to https://app_root_URL/0/odata/SysImage with the JSON raw body with the following content:

{
    "Name": "scr_NewContactPhoto.png",
    "Id": "330006E1-CA4E-4502-A9EC-E54D922D2C01",
    "MimeType": "image/png"
}

330006E1-CA4E-4502-A9EC-E54D922D2C01 should be a random unique identifier. This request will create a record in the SysImage table and the response should be similar to the below:

{
    "@odata.context": "https://app_root_URL/0/odata/$metadata#SysImage/$entity",
    "Id": "330006e1-ca4e-4502-a9ec-e54d922d2c01",
    "CreatedOn": "2021-09-30T10:24:26.830457Z",
    "CreatedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
    "ModifiedOn": "2021-09-30T10:24:26.830457Z",
    "ModifiedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00",
    "ProcessListeners": 0,
    "UploadedOn": "0001-01-01T00:00:00Z",
    "Name": "scr_NewContactPhoto.png",
    "Data@odata.mediaEditLink": "SysImage(330006e1-ca4e-4502-a9ec-e54d922d2c01)/Data",
    "Data@odata.mediaReadLink": "SysImage(330006e1-ca4e-4502-a9ec-e54d922d2c01)/Data",
    "Data@odata.mediaContentType": "application/octet-stream",
    "MimeType": "image/png",
    "HasRef": false,
    "PreviewData@odata.mediaEditLink": "SysImage(330006e1-ca4e-4502-a9ec-e54d922d2c01)/PreviewData",
    "PreviewData@odata.mediaReadLink": "SysImage(330006e1-ca4e-4502-a9ec-e54d922d2c01)/PreviewData",
    "PreviewData@odata.mediaContentType": "application/octet-stream"
}

2) Create a PUT request to https://app_root_URL/0/odata/SysImage(330006e1-ca4e-4502-a9ec-e54d922d2c01)/Data with the binary body and select an image there:

Once executed the response will be 200OK.

 

And after that we can perform a GET request to check the result:

Please also note that BPMCSRF cookie should be always in headers:

Best regards,

Oscar

Hi Oscar,

Thanks for the Guidance, But I want to make an API call from Creatio itself ( Using Web-Service / Script Task ), not from Postman

 

Could you guide me on that? 

Hi Pratik,

 

Please see examples here https://academy.creatio.com/docs/developer/integrations_and_api/data_se…

 

Best regards,

Oscar

Show all comments

I get the message 

"Unable to send email. Contact the site administrator if the problem persists."

every time I add a post.

Why is that ?

Like 0

Like

3 comments

Dear Ricardo, 

 

Thank you for reporting this issue. We've informed the responsible team about it and we will inform you as soon as we get an update from them. 

 

Thank you!

 

Best regards,

Dennis

Hello Ricardo, 

 

We would like to inform you that the issue has been fixed. 

 

Thank you for helping us become better!

 

Best regards,

Olga. 

Olga Avis,

Working fine now. Thanks.

Show all comments

Good day. I have a big task, and the last part is sending the document through a web service.

Generally speaking, I need to send not only a document, but an array of objects, among which there are documents. Documents will be in PDF format.

As I could see, the "Content type" field is protected from changes and is always JSON.

Is there any simple (or at least some) way to accomplish the task sent to me?

I have an example of performing this task in Java and there the document is loaded into the stream and then passed as an attribute ContentReference, but I do not understand how to implement this in bpm'online ..

Like 0

Like

3 comments

It's hard to understand where you want to send the document from. From bpm'online to a third party, or vise versa. If it's from bpm'online please do that via c# in a Script task in a business process. If it's vise versa, please use the same web service that we call when we add a new file to a "File" detail. Please use Fiddler in order to find the service name. 

Eugene Podkovka,

Thank you very much, I finally realized that I had to do this through C# in the Script task, but now I have another problem.

I found a code (https://stackoverflow.com/questions/17027159/how-send-a-pdf-by-post-htt…) that converts the PDF file into bytes and sends them via HttpWebRequest, but I don’t know how to get a document file.

I mean, the Server.MapPath method is used in this example, but I cannot do this. I only know that this document should be on the "Attachments and notes" tab in Contact. Is there a way to get a link to the desired document (by name, etc.) Or use the MapPath function?

I am also trying to figure out how to attach more data than just a file, because the file is just one of them. The following is the complete structure:



If you have any suggestions or tips, please, help me.

Dear Pavlo,

Please note that all documents are saved in the database in the appropriate table. For example, documents from the “Attachments and notes” tab from the Contact section are saved in the “ContactFile” table and have the object name “Contact attachment”. Therefore, it’s possible to read it like ordinary data from the database.

Please note that the column with data of the document has name “Data” and type “varbinary(max)”. In order to read data from the database please use “Read data” element of business process or use ESQ in the code of the Script task element.

Please find more detail instructions about reading and using data in the Script task element from the link below:

https://community.bpmonline.com/questions/how-read-entity-lookup-column-script-task

Best regards,

Norton

Show all comments