This topic describes how to use Content Moderation SDK for .NET to create a business scenario. You can use the business scenario to customize a policy for machine-assisted moderation for the Content Moderation API.

Background information

You can customize a policy for machine-assisted moderation for the Content Moderation API by using the business scenario. By default, you can create up to 100 business scenarios. For more information about parameters, see CreateBizType.

Prerequisites

The dependencies for Content Moderation SDK for .NET are installed. For more information about how to install the dependencies, see Installation.
Note You must use the required versions of the dependencies described in the Installation topic. Otherwise, subsequent operation calls fail.

Create a business scenario

Operation Description Supported region
CreateBizType Creates a business scenario.
  • 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);

            CreateBizTypeRequest createBizTypeRequest = new CreateBizTypeRequest();
            // Set the name of the business scenario that you want to create. 
            createBizTypeRequest.BizTypeName = "Name of the business scenario to be created";
            // Import the configuration of an existing business scenario. This parameter is optional. 
            createBizTypeRequest.BizTypeImport = "Name of an existing business scenario to be imported";
            // Specify whether to import the configuration of an industry template. If you set this parameter to true, you must set the IndustryInfo parameter. This parameter is optional. 
            createBizTypeRequest.CiteTemplate = true;
            // Specify the industry classification. This parameter is required if you set the CiteTemplate parameter to true. Valid values: Social-Registration information-Profile picture and Social-Registration information-Nickname. 
            createBizTypeRequest.IndustryInfo = "Social-Registration information-Profile picture";
            // Specify the response format of the operation. 
            createBizTypeRequest.AcceptFormat = FormatType.JSON;
            // Specify the request method. 
            createBizTypeRequest.Method = MethodType.POST;
            createBizTypeRequest.Encoding = "utf-8";

            // Send the HTTP request to create a business scenario. 
            try
            {
                CreateBizTypeResponse response = client.GetAcsResponse(createBizTypeRequest);

                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));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed with error info: {0}", ex.Message);
            }
        }
    }
}