ContentSafetyClient.AddBlockItems Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddBlockItems(String, AddBlockItemsOptions, CancellationToken) |
Add BlockItems To Text Blocklist. |
AddBlockItems(String, RequestContent, RequestContext) |
[Protocol Method] Add BlockItems To Text Blocklist
|
AddBlockItems(String, AddBlockItemsOptions, CancellationToken)
- Source:
- ContentSafetyClient.cs
Add BlockItems To Text Blocklist.
public virtual Azure.Response<Azure.AI.ContentSafety.AddBlockItemsResult> AddBlockItems (string blocklistName, Azure.AI.ContentSafety.AddBlockItemsOptions addBlockItemsOptions, System.Threading.CancellationToken cancellationToken = default);
abstract member AddBlockItems : string * Azure.AI.ContentSafety.AddBlockItemsOptions * System.Threading.CancellationToken -> Azure.Response<Azure.AI.ContentSafety.AddBlockItemsResult>
override this.AddBlockItems : string * Azure.AI.ContentSafety.AddBlockItemsOptions * System.Threading.CancellationToken -> Azure.Response<Azure.AI.ContentSafety.AddBlockItemsResult>
Public Overridable Function AddBlockItems (blocklistName As String, addBlockItemsOptions As AddBlockItemsOptions, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AddBlockItemsResult)
Parameters
- blocklistName
- String
Text blocklist name.
- addBlockItemsOptions
- AddBlockItemsOptions
The request of adding blockItems to text blocklist.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
blocklistName
or addBlockItemsOptions
is null.
blocklistName
is an empty string, and was expected to be non-empty.
Examples
This sample shows how to call AddBlockItems with required parameters.
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ContentSafetyClient(endpoint, credential);
var addBlockItemsOptions = new AddBlockItemsOptions(new TextBlockItemInfo[]
{
new TextBlockItemInfo("<text>")
{
Description = "<Description>",
}
});
var result = client.AddBlockItems("<blocklistName>", addBlockItemsOptions);
Remarks
Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request.
Applies to
AddBlockItems(String, RequestContent, RequestContext)
- Source:
- ContentSafetyClient.cs
[Protocol Method] Add BlockItems To Text Blocklist
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler AddBlockItems(String, AddBlockItemsOptions, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Response AddBlockItems (string blocklistName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member AddBlockItems : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.AddBlockItems : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function AddBlockItems (blocklistName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response
Parameters
- blocklistName
- String
Text blocklist name.
- content
- RequestContent
The content to send as the body of the request.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
blocklistName
or content
is null.
blocklistName
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call AddBlockItems with required parameters and request content and parse the result.
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ContentSafetyClient(endpoint, credential);
var data = new {
blockItems = new[] {
new {
description = "<description>",
text = "<text>",
}
},
};
Response response = client.AddBlockItems("<blocklistName>", RequestContent.Create(data), new RequestContext());
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("value")[0].GetProperty("blockItemId").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("text").ToString());
Applies to
Azure SDK for .NET