HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In

Change language publish status

Describes how to work with RESTful operations for language versions in the Optimizely Service API.

From Service API 5.3.0, the individual status of a language version can be controlled via the model property PublishStatuses, which is a list of PublishStatus.

Example of PublishStatuses, which sets the individual publish statuses for “en” and “sv” versions.

PublishStatuses = new List<PublishStatus>()
  {
    new PublishStatus()
      {
        IsPublished = true,
        Language = "en",
        StartPublish = now.AddDays(-1),
        StopPublish = now.AddYears(1)
      },
    new PublishStatus()
      {
        IsPublished = false,
        Language = "sv",
        StartPublish = now.AddDays(-1),
        StopPublish = now.AddYears(1)
      }
  }

The PublishStatuses property can be used for nodes and entries.

new Entry
  {
    Code = "Code 3",
    Catalog = "TESTROOTCATALOG",
    EndDate = now.AddYears(1),
    EntryType = "Variation",
    InventoryStatus = "Enabled",
    IsActive = true,
    MetaClass = DefaultEntryMetaClassName,
    Name = "Test",
    StartDate = now.AddDays(-1),
    MetaFields = new List<MetaFieldProperty>
      {
        new MetaFieldProperty
          {
            Name = "Description",
            Type = MetaDataType.LongHtmlString.ToString(),
            Data = new List<MetaFieldData>
              {
                new MetaFieldData
                  {
                    Language="en",
                    Value = "Description"
                  }
              }
          },
        new MetaFieldProperty()
          {
            Name = "DisplayName",
            Type = MetaDataType.ShortString.ToString(),
            Data = new List<MetaFieldData>
              {
                new MetaFieldData()
                  {
                    Language="en",
                    Value = "DisplayName"
                  },
                new MetaFieldData
                  {
                    Language="sv",
                    Value = "DisplayName  in svenska"
                  }
              }
          },
        new MetaFieldProperty
          {
            Name = AnotherMultiLanguageStringMetaFieldName,
            Type = MetaDataType.ShortString.ToString(),
            Data = new List<MetaFieldData>
              {
                new MetaFieldData
                  {
                    Language="EN",
                    Value = "Set with lang key EN for en"
                  },
                new MetaFieldData
                  {
                    Language="Sv",
                    Value = "Set with lang key Sv for sv"
                  }
              }
          },
        Variation = new VariationProperties
          {
            MaxQuantity = 100,
            MinQuantity = 0,
            TaxCategory = "",
            Weight = 5.1,
          },
        Dimension = new DimensionProperties
          {
            Length = 50,
            Height = 60,
            Width = 70
          },
        PublishStatuses = new List<PublishStatus>()
          {
            new PublishStatus()
              {
                IsPublished = true,
                Language = "en",
                StartPublish = now.AddDays(-1),
                StopPublish = now.AddYears(1)
              },
            new PublishStatus()
              {
                IsPublished = false,
                Language = "sv",
                StartPublish = now.AddDays(-2),
                StopPublish = now.AddYears(2)
              }
          }
  }

Example of a returned JSON.

{  
  "IsActive"              : true,
  "MetaFields"            : [  
    {  
      "Data" : [  
        {  
          "Language" : "en",
          "Value"    : ""
        },
        {  
          "Language" : "sv",
          "Value"    : "Set with lang key Sv for sv"
        }
      ],
      "Name" : "AnotherMultilanguageString",
      "Type" : "ShortString"
    },
    {  
      "Data" : [  
        {  
          "Language" : "en",
          "Value"    : "13.440000000"
        },
        {  
          "Language" : "sv",
          "Value"    : "15,230000000"
        }
      ],
      "Name" : "DecimalType",
      "Type" : "Decimal"
    },
    {  
      "Data" : [  
        {  
          "Language" : "en",
          "Value"    : "Description"
        },
        {  
          "Language" : "sv",
          "Value"    : "Description"
        }
      ],
      "Name" : "Description",
      "Type" : "LongString"
    },
    {  
      "Data" : [],
      "Name" : "DictionaryMulti",
      "Type" : "EnumMultiValue"
    },
    {  
      "Data" : [  
        {  
          "Language" : "en",
          "Value"    : ""
        },
        {  
          "Language" : "sv",
          "Value"    : ""
        }
      ],
      "Name" : "DictionarySingle",
      "Type" : "DictionarySingleValue"
    },
    {  
      "Data" : [  
        {  
          "Language" : "en",
           "Value"    : "DisplayName"
        },
        {  
          "Language" : "sv",
          "Value"    : "DisplayName in svenska"
        }
      ],
      "Name" : "DisplayName",
      "Type" : "ShortString"
    },
    {  
      "Data" : [  
        {  
          "Language" : "en",
          "Value"    : ""
        },
        {  
          "Language" : "sv",
          "Value"    : ""
        }
      ],
      "Name" : "IntegerMetaFieldName",
      "Type" : "Int"
    },
    {  
      "Data" : [  
        {  
          "Language" : "en",
          "Value"    : "hello;world"
        },
        {  
          "Language" : "en",
          "Value"    : "hi;there"
        },
        {  
          "Language" : "sv",
          "Value"    : "hello;world"
        },
        {  
          "Language" : "sv",
          "Value"    : "hi;there"
        }
      ],
      "Name" : "AStringDictionaryMetaField",
      "Type" : "StringDictionary"
    },
    {  
      "Data" : [ ],
      "Name" : "_ExcludedCatalogEntryMarkets",
      "Type" : "EnumMultiValue"
    }
  ],
  "SeoInformation"        : [  
    {  
      "LanguageCode" : "en",
      "Title"        : null,
      "Uri"          : "Test-en.aspx",
      "UriSegment"   : "test",
      "Description"  : null,
      "Keywords"     : null
    },
    {  
      "LanguageCode" : "sv",
      "Title"        : null,
      "Uri"          : "Test-sv.aspx",
      "UriSegment"   : "test",
      "Description"  : null,
      "Keywords"     : null
    }
  ],
  "PublishStatuses"       : [  
    {  
       "Language"     : "en",
       "IsPublished"  : true,
       "StartPublish" : "2018-11-14T10:24:00.257Z",
       "StopPublish"  : "2019-11-15T10:24:00.257Z"
    },
    {  
       "Language"     : "sv",
       "IsPublished"  : false,
       "StartPublish" : "2018-11-14T10:24:00.257Z",
       "StopPublish"  : "2019-11-15T10:24:00.257Z"
    }
  ],
  "Code"                 : "Code 3",
  "Name"                 : "Test",
  "StartDate"            : "2018-11-14T10:24:00.257Z",
  "EndDate"              : "2019-11-15T10:24:00.257Z",
  "MetaClass"            : "DefaultMetadataClass",
  "Catalog"              : "TESTROOTCATALOG",
  "Prices"               : [],
  "EntryType"            : "Variation",
  "ChildCatalogEntries"  : [],
  "InventoryStatus"      : "Enabled",
  "WarehouseInventories" : [],
  "Associations"         : [],
  "Assets"               : [],
  "Nodes"                : [],
  "Variation"            : {  
    "MinQuantity" : 0.000000000,
    "MaxQuantity" : 100.000000000,
    "Weight"      : 5.1,
    "TaxCategory" : ""
  },
  "Dimension"            : {  
    "Length" : 50.0,
    "Height" : 60.0,
    "Width"  : 70.0  
  }
}

You can use PublishStatuses in both POST (create) and PUT (update) operations. It will be returned in GET operations.

For POST and PUT, if PublishStatuses is null, it is skipped. You also can update the statuses of some, but not all, languages.

📘

Note

  • If IsActive is set to false, it overrides the IsPublished status of all languages.
  • You cannot “unpublish” the master language version. There must be always a published, master language version.
  • You cannot "unpublish" a published version. If you have a draft version in a non-master language, set IsPublished to false for that language to keep in draft. If it is published, setting IsPublished to false has no effect. Use StartPublish and StopPublish to expire the content instead.
  • While you can send a list with duplicated languages, only the first matching publish status for a language is used.
  • StartPublish and StopPublish of a master language override StartDate and EndDate.

What’s Next