When you need to create a standard or custom Tag barcode, a QR Code, or NFC URL, Microsoft Tag Manager lets you make one individually in just a minute or two. But if you need to create and manage a lot of Tag recognition technologies, the Microsoft Tag Creation API is the quickest, easiest solution. The API is exposed as a web service, so you can easily integrate Tag management into new or existing applications.
With the Tag Creation API you can build and update multiple Tags programmatically, using Visual Studio and the .NET Framework, over the web and on a range of other devices, including:
The API gives you access to many of the same operations that are available in Microsoft Tag Manager, but automation streamlines the processes and minimizes input errors.
1. Referencing the Tag Web Service
Follow these steps:
- Create a Visual Studio project.
- In Visual Studio project explorer, right-click on Service Reference and click Add Service Reference.
- Copy and paste the URI https://ws.tag.microsoft.com/MIBPService.wsdl in the Address entry.
- Change the Namespace to something relevant to your project and then click OK.
- In the inline code of your Page/Class, add the following use statement: using ProjectName.Namespace;
2. Creating a Tag
private void CreateTag()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
URITag uriTag = new URITag();
uriTag.Title = "My Tag Title";
uriTag.MedFiUrl = "http://www.something.com";
uriTag.UTCStartDate = new DateTime(yyyy, mm, dd);
uriTag.UTCEndDate = new DateTime(yyyy, mm, dd);
uriTag.PublicTitle = "My Tag Public Title";
OMIBPClient.CreateTag(oCredential, "Main", uriTag);
}
catch
{
throw;
}
}
3. Editing a Tag
private void UpdateTag()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
vTag.Title = "New Tag Title ";
OMIBPClient.UpdateTag(oCredential
, "Category name"
, "Existing Tag Title"
, vTag);
}
catch
{
throw;
}
}
4. Pausing or activating a Tag
private void ActivateTag()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
OMIBPClient.ActivateTag(oCredential, "Category Name", "Tag Title");
}
catch
{
throw;
}
}
private void PauseTag()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
OMIBPClient.PauseTag(oCredential, "Category Name", "Tag Title");
}
catch
{
throw;
}
}
5. Creating a category
private void CreateCategory()
{
try
{
Category oCat = new Category();
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
oCat.Name = "Category Name";
oCat.UTCEndDate = new DateTime(yyyy, mm, dd);
oCat.UTCStartDate = new DateTime(yyyy, mm, dd);
OMIBPClient.CreateCategory(oCredential, oCat);
}
catch
{
throw;
}
}
6. Editing a category
private void UpdateCategory()
{
try
{
Category oCat = new Category();
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
oCat.Name = "New Category Name";
oCat.UTCEndDate = new DateTime(yyyy, mm, dd);
oCat.UTCStartDate = new DateTime(yyyy, mm, dd);
OMIBPClient.UpdateCategory(oCredential, "Category Name", oCat);
}
catch
{
throw;
}
}
7. Pausing or activating a category
private void ActivateCategory()
{
try
{
Category oCat = new Category();
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
OMIBPClient.ActivateCategory(oCredential, "Category Name");
}
catch
{
throw;
}
}
private void PauseCategory()
{
try
{
Category oCat = new Category();
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
OMIBPClient.PauseCategory(oCredential, "Category Name");
}
catch
{
throw;
}
}
8. Rendering a Tag
private void RenderTag()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
byte[] oBarcode = OMIBPClient.GetBarcode(
oCredential, Category Name, Tag Name,
ImageTypes.tiff, Size,
DecorationType.HCCBRP_DECORATION_NONE,
Is Black or White);
//render the oBarcode byte array into an image.
}
catch
{
throw;
}
}
9. Render as a QR Code
private void RenderQR()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
byte[] oBarcode = OMIBPClient.GetQR(
oCredential, Category Name, Tag Name,
ImageTypes.tiff, Size,
Include Help Text);
//render the oBarcode byte array into an image.
}
catch
{
throw;
}
}
10. Get the URL associated with the Tag
private void GetDirectUrl()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
string url = OMIBPClient.GetDirectUrl(oCredential,
Category Name,
Tag Name);
//do something with the URL
}
catch
{
throw;
}
}
11. Get the URL associated with the QR Code
private void GetQRUrl()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
string url = OMIBPClient.GetQRUrl(oCredential,
Category Name,
Tag Name);
//do something with the URL
}
catch
{
throw;
}
}
12. Get the URL associated with NFC
private void GetNfcUrl()
{
try
{
MIBPContractClient OMIBPClient = new MIBPContractClient();
UserCredential oCredential = new UserCredential();
oCredential.AccessToken = "Enter your access token";
string url = OMIBPClient.GetNfcUrl(oCredential,
Category Name,
Tag Name);
//do something with the URL
}
catch
{
throw;
}
}