Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Luis Pedro Pereira 13 posts 93 karma points
    Mar 22, 2018 @ 15:55
    Luis Pedro Pereira
    0

    Creating Vorto content with Content API

    Hello.

    I´m trying to use the Content API to create my data, that as a Vorto object inside, but, the main and non-vorto fields are created, and the vorto fields aren't.

    I'm using this code. Is there something that should be changed? (I always got Success. Non-vorto fields not represented here, because they are working fine).

    TIA, /Luis

                VortoValue vortoValues = new VortoValue();
                vortoValues.Values = new Dictionary<string, object>();
    
                vortoValues.Values.Add("en", new MyPressClass()
                {
                    pageTitle = "This is the page title",
                    text = "<p>This is the content text</p>"
                });
                vortoValues.Values.Add("dk", new MyPressClass()
                {
                    pageTitle = "Dette er siden titel",
                    text = "<p>Dette er indholdet tekst</p>"
                });
    
                var newContent = Services.ContentService.CreateContent("New document", 1234, "myDataType");
                newContent.SetValue("vortoContent", JsonConvert.SerializeObject(vortoValues));
    
                var result = Services.ContentService.SaveAndPublishWithStatus(newContent);
    
                if (result.Success)
                    iTotal++;
                else
                    iErrors++;
    
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 22, 2018 @ 18:04
    Alex Skrypnyk
    0

    Hi

    I'm not sure that this is the case, but are you sure that culture name should be 2 letters?

    /Alex

  • Luis Pedro Pereira 13 posts 93 karma points
    Mar 22, 2018 @ 18:12
    Luis Pedro Pereira
    0

    Hi Alex.

    Unless there's some issue when creating trough the Content API, it should work also with only 2 letters in the culture, because it wrwhen saving data from the backoffice and also it is possible to chose cultures with only two letters in the languages settings.

    /Luis

Please Sign in or register to post replies

Write your reply to:

Draft