I have a problem about uploading pdf. Please help me

Good Day!
I’m a dolibarr beginner.
I’m putting vbscript by using Dolibarr API in Kofax autostore environment.
/documents/upload
https://…with2.dolicloud.com/api/index.php/documents/upload
I’m going to use the above API.
But I don’t know about arguments of this API.
{
“filename”: “string”,
“modulepart”: “string”,
“ref”: “string”,
“subdir”: “string”,
“filecontent”: “string”,
“fileencoding”: “string”,
“overwriteifexists”: 0
}

I want to upload “c:\test.pdf” file.
So, would you possible know me how to use this parameters?

I put “C:\test.pdf” in the “filename” parameter.
but error occurs.
And I don’t know about “subdir” parameter.
If you possible, please show me how to do kindly.
Thanks :slight_smile:

Probably you know this already, but there is an API explorer available as part of your Dolibarr installation, providing some useful information about the REST interface. Its available under /api/index.php/explorer

There can also be found some documentation regarding the file upload parameters:

createDocumentsModel {
filename (string): Name of file to create ('FA1705-0123.txt') ,
modulepart (string): Name of module or area concerned by file upload 
('facture', 'project', 'project_task', ...) ,
ref (string, optional): Reference of object 
(This will define subdir automatically and store submited file into it) ,
subdir (string, optional): Subdirectory 
(Only if ref not provided) ,
filecontent (string, optional): File content
(string with file content. An empty file will be created 
if this parameter is not provided) ,
fileencoding (string, optional): File encoding 
(''=no encoding, 'base64'=Base 64) ,
overwriteifexists (integer, optional): Overwrite file if exists 
(1 by default) ,
createdirifnotexists (integer, optional): Create subdirectories if the doesn't exists 
(1 by default)
}

Hope this is helpful.

Thanks for reply :slight_smile:
I have referenced the following link.
https://…with2.dolicloud.com/api/index.php/explorer/#/document
(I have a token key.)
but I don’t to know how to put the value in the “filename” parameter.
I want to put “c:\test.pdf” value in the “filename” parameter.
But error occurs.
I should to upload c:\test.pdf file by using api/index.php/documents/upload API.
If possible, would you please tell me detail? :sweat_smile:

I think the filename parameter contains the name of the created file AFTER the upload, not the name of the file on your disc.

You need to locally read the file, which you want to upload, and put its content in the parameter filecontent. How this is done exactly, depends on your local system. So you need to figure this out with VBScript.

Don’t forget to set the other parameters: modulepart and either a value for ref or for subdir and to choose the correct fileencoding.

Thanks for good support.

I am using this API and followed all details given ini explorer. But whenever I am uploading any file its uploading successfully but giving corrupted file.

Have you faced this issue? Any solution for this?

Did you check, whether the parameter for the file encoding is set correctly according to the encoding of the content you are transmitting? If not in base64, try using that (and of course convert the content to this format before transmitting it).

Yes @priojk .

As per document, for images i am using fileencoding: base64 & for pdf and docx I am using fileencoding: ‘’.

Still when I save file it gives corrupt file for image & pdf.