Help Center/
Content Moderation/
SDK Reference/
Using the .NET SDK/
SDK Calling Example/
Moderation (Image)/
Image Moderation (Asynchronous Batch) (V2)/
Querying a Task
Updated on 2023-07-17 GMT+08:00
Querying a Task
- This section describes how to use the Image Moderation (Asynchronous Batch) SDK for querying a task by AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. Set JobId in RunCheckResultRequest to configure the ID of the moderation task, 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 RunCheckResultSolution { 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 RunCheckResultRequest { JobId = "2991572e-f503-11eb-a32d-88bd0dde8061" }; try { var resp = client.RunCheckResult(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 querying the Image Moderation (Asynchronous Batch) task is displayed on the console.
200 {'result': {'create_time': '2021-08-04T08:30:41Z', 'items': [{'category_suggestions': { 'porn': 'pass', }, 'detail': {'ad': None, 'porn': [{'confidence': 0.9883, 'label': 'normal'}, {'confidence': 0.0039, 'label': 'porn'}, {'confidence': 0.0078, 'label': 'sexy'}], 'suggestion': 'pass', 'url': 'https://sdk-obs-source-save.obs.cn-north-4.myhuaweicloud.com/terrorism.jpg'}], 'job_id': 'xxx', 'status': 'finish', 'update_time': '2021-08-04T08:30:41Z'}}
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