123
and 456
for your two articles.
/items/external-id/<YOUR_ITEM_EXTERNAL_ID>
endpoint.
In the body of the request, specify the item's name and content type.
See more details on upserting content items.
Import content by upserting a language variant.
Send a PUT request to the endpoint specifying the language variant you want to insert or update. In the body of the request, specify the values of individual content elements.
Notice that you are referencing the Donate with us item even though you haven't imported it yet. Such references are not visible in the UI.
"related_articles": [
{
"external_id": "456"
}
]
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;
var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_ENVIRONMENT_ID>"
});
await client.UpsertContentItemAsync(
Reference.ByExternalId("123"),
new ContentItemUpsertModel { Name = "On Roasts", Type = Reference.ByCodename("article") });
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;
var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_ENVIRONMENT_ID>"
});
var identifier = new LanguageVariantIdentifier(Reference.ByExternalId("123"), Reference.ByCodename("en-US"));
var response = await client.UpsertLanguageVariantAsync(identifier, new LanguageVariantUpsertModel
{
Elements = new dynamic[]
{
new TextElement
{
Element = Reference.ByCodename("title"),
Value = "On Roasts"
}.ToDynamic(),
new LinkedItemsElement
{
Element = Reference.ByCodename("related_articles"),
Value = new []
{
Reference.ByExternalId("456"),
}
}.ToDynamic()
}
});
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;
var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_ENVIRONMENT_ID>"
});
await client.UpsertContentItemAsync(
Reference.ByExternalId("456"),
new ContentItemUpsertModel { Name = "Donate with us", Type = Reference.ByCodename("article") });
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;
var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_ENVIRONMENT_ID>"
});
var identifier = new LanguageVariantIdentifier(Reference.ByExternalId("456"), Reference.ByCodename("en-US"));
await client.UpsertLanguageVariantAsync(identifier, new LanguageVariantUpsertModel
{
Elements = ElementBuilder.GetElementsAsDynamic(new BaseElement[]
{
new TextElement
{
Element = Reference.ByCodename("title"),
Value = "Donate with us"
},
new LinkedItemsElement
{
Element = Reference.ByCodename("related_articles"),
Value = new []
{
Reference.ByExternalId("123"),
}
}
})
});