How to use API to Populate a Content Type with lots of Data
Hi:
I'm new to Umbraco and I wish to polulate an Umbraco Document Type with lots of data programmatically.
I have created a News Article content type which has the following fields. Title, Description,Date, Contact, Email Address, Comments (RTE).
Is there a way (Ie. VS 2013 Console application I think) to programmaticllay populate my new Content Type Table using the Umbraco API? I have test data I wish to populate but need to know what api's to use.
As Jan said, you can use the ContentService API for this purpose.
If you are using the SurfaceController, there's a property Services which contains the ContentService.
For your news example:
Create an IContent instance with contentService.CreateContent(...) and assign the values with SetValue().
When you are done you can save the new content with contentService.SaveAndPublishWithStatus(yourInstance, ...).
PS. You will need at least references to Umbraco.Web and Umbraco.Core
You don't need to code to get all data in, you can also use CMSImport. Simply map from datasource to the document properties and press import. Free for 500 records more info can be found at http://soetemansoftware.nl/cmsimport
How to use API to Populate a Content Type with lots of Data
Hi:
I'm new to Umbraco and I wish to polulate an Umbraco Document Type with lots of data programmatically.
I have created a News Article content type which has the following fields.
Title, Description,Date, Contact, Email Address, Comments (RTE).
Is there a way (Ie. VS 2013 Console application I think) to programmaticllay populate my new Content Type Table using the Umbraco API? I have test data I wish to populate but need to know what api's to use.
Thanks
Tom
Hi Tom and welcome to our :)
I'm not a .NET developer myself, but I think that you can benefit from having a look at the content service API here
http://our.umbraco.org/documentation/Reference/Management-v6/Services/
/Jan
Thanks.
I'm still a newbee. Do you knwo what dll to reference?
Hi!
As Jan said, you can use the
ContentService
API for this purpose.If you are using the SurfaceController, there's a property
Services
which contains the ContentService.For your news example:
Create an
IContent
instance withcontentService.CreateContent(...)
and assign the values withSetValue()
.When you are done you can save the new content with
contentService.SaveAndPublishWithStatus(yourInstance, ...)
.PS. You will need at least references to Umbraco.Web and Umbraco.Core
Hi,
You don't need to code to get all data in, you can also use CMSImport. Simply map from datasource to the document properties and press import. Free for 500 records more info can be found at http://soetemansoftware.nl/cmsimport
Hope that can help also.
Best,
Richard
Thanks everyone. You're all so very helpful.
is working on a reply...