This topic describes how to use Content Moderation SDK for .NET to query existing and custom business scenarios. This helps you manage business scenarios.

Background information

For more information about parameters, see DescribeUserBizTypes.

Query business scenarios

Operation Description Supported region
DescribeUserBizTypes Queries business scenarios.
  • cn-shanghai: China (Shanghai)
  • cn-beijing: China (Beijing)
  • cn-shenzhen: China (Shenzhen)
  • ap-southeast-1: Singapore (Singapore)

Sample code

using System;
using Newtonsoft.Json;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Green.Model.V20170823;
using System.Collections.Generic;


namespace csharp_sdk_sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Use the AccessKey ID and AccessKey secret of your Alibaba Cloud account. 
            IClientProfile profile = DefaultProfile.GetProfile(
                "cn-shanghai",
                "Your AccessKey ID",
                "Your AccessKey secret");
            DefaultAcsClient client = new DefaultAcsClient(profile);

            DescribeUserBizTypesRequest describeUserBizTypesRequest = new DescribeUserBizTypesRequest();
            // Specify the response format of the operation. 
            describeUserBizTypesRequest.AcceptFormat = FormatType.JSON;
            // Specify the request method. 
            describeUserBizTypesRequest.Method = MethodType.GET;
            describeUserBizTypesRequest.Encoding = "utf-8";
            try
            {
                DescribeUserBizTypesResponse response = client.GetAcsResponse(describeUserBizTypesRequest);
                if (response.HttpResponse.Status != 200)
                {
                    Console.WriteLine("the request failed. status:{0}", response.HttpResponse.Status);
                }
                Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
                // The list of all business scenarios. 
                Console.WriteLine("query success. bizTypes size :" + response.BizTypeList.Count);
                foreach (DescribeUserBizTypesResponse.DescribeUserBizTypes_Item bizTypeItem in response.BizTypeList)
                {
                    // The name of the business scenario. 
                    Console.WriteLine(bizTypeItem.BizType);
                    // Indicates whether an industry template was imported. 
                    Console.WriteLine(bizTypeItem.CiteTemplate);
                    // The industry information. 
                    Console.WriteLine(bizTypeItem.IndustryInfo);
                    // The source of the business scenario. A value of custom indicates a custom business scenario. A value of system indicates the default business scenario of Content Moderation. 
                    Console.WriteLine(bizTypeItem.Source);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed with error info: {0}", ex.Message);
            }
        }
    }
}