Hello, I need to create a React portlet that invokes the headless APIs of an Object to create an object entry by entering a series of data, including uploading a file.
To upload a file, do I first need to invoke the headless APIs to load the file into the DML? Does anyone have an example or a list of APIs that I should invoke to achieve my goal?
Can we specify a folder in the POST payload in which upload the file ONLY for object fields with "Upload or Select from Documents and Media Item Selector" option? @ChrisHof
There are two ways to attach the files, the first one is upload the file in the documents & media portlet, and then pass the id of the file in the body, like below:
{
"name": "EXAMPLE01",
"attachmentField": 34050 // this is fileentryid, and can be obtained from dlfileentry table
}
The second is to upload the file using base64 encoding, and for that, you can refer to the following request body:
https://learn.liferay.com/w/dxp/integration/headless-apis/object-apis/custom-object-apis/using-object-apis-with-base64-encoded-files#posting-an-attachment-uploaded-directly-from-the-users-computer
– ChrisHofCan we specify a folder in the POST payload in which upload the file ONLY for object fields with "Upload or Select from Documents and Media Item Selector" option? @ChrisHof
– MoozoYes, you just have to check the OpenAPI definition in API Explorer for your Object for all the fields in the request body...
– ChrisHofFor attachment fields in the schema I see only "{}", so I dont know which parameters I Need to send...
– Moozo