Help Center/
Content Moderation/
SDK Reference/
Using the .NET SDK/
SDK Calling Example/
Moderation (Image)/
Image Moderation (Asynchronous Batch) (V2)/
Submitting a Task
Updated on 2023-07-17 GMT+08:00
Submitting a Task
- This section describes how to use the Image Moderation SDK by AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. You can set Urls in RunTaskSumbitRequest to configure the URLs of the images to be reviewed, and then execute the code.
using System; using System.Collections.Generic; using HuaweiCloud.SDK.Core; using HuaweiCloud.SDK.Core.Auth; using HuaweiCloud.SDK.Moderation; using HuaweiCloud.SDK.Moderation.V2; using HuaweiCloud.SDK.Moderation.V2.Model; namespace RunTaskSumbitSolution { class Program { static void Main(string[] args) { //Enter your AK/SK. const string ak = "<YOUR AK>"; const string sk = "<YOUR SK>"; var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk); var client = ModerationClient.NewBuilder() .WithCredential(auth) .WithRegion(ModerationRegion.ValueOf("xxx")) //Replace xxx with the region where the service is located. .WithHttpConfig(config) .Build(); var req = new RunTaskSumbitRequest { }; List<TaskSumbitReq.CategoriesEnum> listTaskSumbitReqCategories = new List<TaskSumbitReq.CategoriesEnum>(); listTaskSumbitReqCategories.Add(TaskSumbitReq.CategoriesEnum.FromValue("porn")); List<String> listTaskSumbitReqUrls = new List<String>(); listTaskSumbitReqUrls.Add("https://XXX.jpg"); //Replace it with an image URL that can be accessed from the Internet. req.Body = new TaskSumbitReq() { Categories = listTaskSumbitReqCategories, Urls = listTaskSumbitReqUrls }; try { var resp = client.RunTaskSumbit(req); var respStatusCode = resp.HttpStatusCode; Console.WriteLine(respStatusCode); Console.WriteLine(JsonConvert.DeserializeObject(resp.HttpBody)); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } } } }
- If 200 is displayed on the console, the code is successfully executed. The result of submitting the Image Moderation (Asynchronous Batch) task is displayed on the console.
200 {'result': {'job_id': 'xxx'}}
Parent topic: Image Moderation (Asynchronous Batch) (V2)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot