Generate a document
Audience:
•
Version: 10
Some tooltip text!
• 2 minutes to read
• 2 minutes to read
var doc = {}
doc.Header = "Testing test";
doc.Name = "foo.doc";
doc.OurRef = "foo/1";
doc.YourRef = "bar/99";
doc.Description = "BAZ FTW";
doc.DocumentTemplate = { DocumentTemplateId = 2 };
doc.Contact = { ContactId = 25 };
doc.Person = { PersonId = 63, ContactId = 25, };
doc = Post("api/v1/Document", doc);
At this point, the document record has been created, but the content is not generated yet. We can either upload some content directly:
id = res.DocumentId;
content = "This is some document content.";
Put("api/v1/Document/" + id + "/content", content)
Or we can use the document template to generate a fresh document for us:
id = res.DocumentId;
Post("api/v1/Document/" + id + "/content")
content = Get("api/v1/Document/" + id + "/content")
This will generate a new document based on the template and return the updated document object to us.
Note
The examples are given in JavaScripty pseudocode.