Creates a new Tag within a specified Category.
Namespace: Microsoft.Tag.CampaignManagementAssembly: Microsoft.Tag.CampaignManagement (in Microsoft.Tag.CampaignManagement.dll) Version: 1.0.7785.0 (1.0.7785.0)
Syntax
| C# |
|---|
bool CreateTag( UserCredential userCredential, string categoryName, Tag tag ) |
| Visual Basic |
|---|
Function CreateTag ( _ userCredential As UserCredential, _ categoryName As String, _ tag As Tag _ ) As Boolean |
| Visual C++ |
|---|
bool CreateTag( UserCredential^ userCredential, String^ categoryName, Tag^ tag ) |
Parameters
- userCredential
- Type: Microsoft.Tag.CampaignManagement..::..UserCredential
A 64-bit encrypted GUID specifying the user credential.
- categoryName
- Type: System..::..String
The name of the category that will contain the new Tag.
- tag
- Type: Microsoft.Tag.CampaignManagement..::..Tag
The Tag object containing the information for the new Tag.
Return Value
true if the method succeeds
false if the method fails
Remarks
CreateTag creates a new Tag of any of four Tag types in an existing Category. When creating the new Tag, you assign a Title (name), a Start Date and, optionally, an End Date for the Tag. If no End Date is assigned, the Tag will not expire.
The Start Date and End Date must be within the bounds of the containing Category's Start and End Dates, or the method will fail.
CreateTag fails when any of the following invalid parameters is passed:
- Category not found.
- Category has an invalid status.
- Category is paused.
- Tag has duplicate name.
- Tag has dates lie outside the bounds of the containing Category's dates.
- Tag has dates which conflict (e.g. the Start Date is after the End Date).
Examples
This code sample demonstrates how to call CreateTag(UserCredential, String, Tag).
CopyC#
private void LocalCreateTag() { try { MIBPContractClient OMIBPClient = new MIBPContractClient(); UserCredential oCredential = new UserCredential(); oCredential.AccessToken = "Enter your access token"; URITag uriTag = new URITag(); uriTag.MedFiUrl = "http://www.something.com"; uriTag.UTCStartDate = new DateTime(yyyy, mm, dd); uriTag.UTCEndDate = new DateTime(yyyy, mm, dd); OMIBPClient.CreateTag(oCredential, "Main", uriTag); } catch { throw; } }