function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion


I am trying to add a document to a document folder with the following code, and I am calling this method from a JUnit test script that is passing in hard coded values and I am getting


I obtained the authorId and folderId's from a view source of the Web Pages associated with the folder where I want to create the document. I have already created a folder on salesforce using a similar method called CreateFolder().

I cannot find a reference for this status code in the documentation or in this forum.

public String CreateDocument(String docName, File doc, String description, ID authorId, ID folderId) {
String retStatus = "Success";
int fileLength = (int)doc.length();
byte[] body = new byte[fileLength];

//Verify that we are already authenticated, if not
//call the login function to do so
if (!loggedIn) {
if (!login()) {
return "Bad SalesForce Login";
try {
FileInputStream fis = new FileInputStream(doc);
fileLength =;
catch (FileNotFoundException e) {
retStatus = "Error Failed to CreateDocument:" + e.getLocalizedMessage();
return retStatus;
catch (IOException e1) {
retStatus = "Error Failed to CreateDocument:" + e1.getLocalizedMessage();
return retStatus;

try {
Document document;
SObject[] accs = new SObject[1];
document = new Document();


accs[0] = document;

//create the object(s) by sending the array to the web service
SaveResult[] sr = binding.create(accs);
for (int i = 0; i < sr.length; i++) {
SaveResult result = sr[i];
if (result.isSuccess()){
retStatus = "Success Created Document " + docName;
} else {
Error[] ers = (Error[]) result.getErrors();
retStatus = "Error:";
for (int j = 0; j < ers.length; j++) {
Error error = ers[j];
retStatus += error.getMessage() + ";";
System.out.println("error.getStatusCode():" + error.getStatusCode());
catch (UnexpectedErrorFault uef) {
catch (Exception ex) {
retStatus = "\nFailed to create folder, " + docName + ", error message was: \n"
+ ex.getMessage();

return retStatus;
I believe the problem may be with the authorId which is required but all I have is the 15 char ID, is this statuscode because the authorId is a 15 char vs. 18 char?

Hi Ollie,

This error is typically associated with a deleted object.  To be sure the folder is not deleted, get it's id using the API first.

Nope, the user id from the LoginResult is 18 chars.  In any event, the id fields accept 15 and 18.
Well when I changed the authorId from 15 char to 18 char version and created the document, the error went perhaps not all fields accept both...;-)
for clarity I had obtained the authorId from doing a view source on the Web UI of SalesForce, not from the loginResult where I got the 18 char that worked.

hello, i have got 15 digit ID but where can i geet 18 digit ID..?