Upload to DocStar using REST

Before you tell me to run a trace, I already did and got this far:

  • POST Ice.BO.AttachmentSvc/DocStarFileExistsForTableRow
  "docTypeID": "DOCSTR",
  "parentTable": "QuoteHed",
  "fileName": "string",
  "foreignSysRowID": "22d9899d-0978-47ca-b718-7399b8be092f"
  • POST Ice.BO.AttachmentSvc/DocStarUploadFile
  "fileName": "string",
  "data": "string",
  "docTypeID": "DOCSTR",
  "parentTable": "QuoteHed",
  "metadata": {}
  • Save returned filename


  1. When I try to POST to DocStarUploadFile in the Swagger UI, I only get an internal server error with no clue what the problem was.
  2. I don’t see anything in the trace showing how to actually attach the document to the quote after uploading to DocStar.

Any help? Here’s my trace:

TraceData2416.txt (552.3 KB)

Try enabling server logging and see if you get more details about DocStarUploadFile

Now about attaching the doc to the quote, you would need some additional calls.

GetNewQuoteHedAttch gets a new QuoteHedAttch record empty with RowMod A

DocStarFileExistsForTableRow to retrieve the details for the file you just uploaded, the result of the call is XFileRefNum, and you also get XFileName and AttachNum as output parameters.

Use above values to populate the empty QuoteHedAttch row in the dataset, then simply call Update.

This is based on the trace, I’m not really familiar with attachments.

You have to pass in the file data base64 encoded

Byte[] bytes = File.ReadAllBytes(result);
String fileData = Convert.ToBase64String(bytes);
var file = new
	fileName = $"{ud03Record.Key5}.pdf",
	data = fileData,
	docTypeID = "PGOrderD",
	parentTable = "UD103",
	metadata = new
		_Author = "Epicor PG Importer",
		_TableName = "Ice.UD03",
		_TableSysRowID = addedUDRecord.SysRowID.ToString()
var addedDocStarFile = EpicorRest.DynamicPost("Ice.BO.AttachmentSvc", "DocStarUploadFile", file);

Then you need to create the XFileRef and XFileAttach records

//Create XFile Ref
var xFileRef = new { Company =company, XFileName = addedDocStarFile.ds.ToString(), XFileDesc = file.fileName, DocTypeID = "PGOrderD" };
var addedXRef = EpicorRest.DynamicPost("Ice.BO.XFileRefSvc", "XFileRefs", xFileRef);

//Create the attachment Record
var UD103Attch = new
	DrawDesc = $"{addedUDRecord.Key1}-{addedUDRecord.Key2}-{addedUDRecord.Key3}-{addedUDRecord.Key4}",
	FileName = addedXRef.XFileName,
	DocTypeID = file.docTypeID,
	ForeignSysRowID = addedUDRecord.SysRowID,
	RowMod = "A"
var newUDAttch = EpicorRest.DynamicPost("Ice.BO.UD103Svc", "UD103Attchs", UD103Attch);