Developer Q&A

Ask a Question
Back to All

Create work order with file upload error

When creating a work order with a File upload I'm receiving the following error.

Error dehydrating property value for Corrigo.BO.Common.DmDoc.DocType

From the docs I see that DocType is just a description and displayAs which are just strings so not sure what fields I'm missing on the DocType.

I've specified all the required fields on the document object. What is the minimum amount of things needed to have a document added to a work order on ticket creation with the WoCreateCommand?

http://securecontent.corrigo.com/docs/HelpCE92/html/42ce1828-0e5a-bc8b-90bf-21dca20cdd13.htm

For current document created I had the following set.

public static Document CreateDocumentObject(SubmitTicket ticket)
{
var blob = CreateMemoryStream(ticket);

        var document = new Document
        {
            ActorTypeId = ActorType.WO,
            Title = Path.GetFileName(File.FileName),
            Description = "", //leaving as blank string.  Is Required
            ActorId = CurrentUserNumber, //Id of document owner. Is required.
            IsPublic = true,
            MimeType = File.ContentType,
            StartDate = DateTime.UtcNow,
            Blob = new Blob
            {
                ActorTypeId = ActorType.WO,
                FileName = FileName,
                ActorId = ticket.CurrentUserNumber,
                Body = blob
            },
            DocType = new DocumentType
            {
                DisplayAs = Path.GetFileName(File.FileName),
                Description = ""
            }
        };
        return document;
    }

    public static byte[] CreateMemoryStream(SubmitTicket ticket)
    {
        using (var memoryStream = new MemoryStream())
        {
            ticket.File.InputStream.CopyTo(memoryStream);
            return memoryStream.ToArray();
        }
    }

For the document part of the WorkOrder I'm setting it like the below.

Documents = new Document[]
{
document
}