แชร์ผ่าน


DeleteAttribute Class

Definition

Defines an API DELETE method.

public ref class DeleteAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class DeleteAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type DeleteAttribute = class
    inherit Attribute
Public NotInheritable Class DeleteAttribute
Inherits Attribute
Inheritance
DeleteAttribute
Attributes

Examples

[AutoClient("MyClient")]
interface IMyDependencyClient
{
    [Delete("/api/users/{userId}")]
    Task<bool> DeleteUserAsync(string userId, CancellationToken cancellationToken = default);
}

Remarks

Marks a method within an interface annotated with AutoClientAttribute as an API DELETE method.

The return type of an API method must be a Task<T>. If T is a String and the dependency returns "text/plain" content type, the result will be the raw content of the response. Otherwise, it will be deserialized from JSON. If T is of type HttpResponseMessage, the result will be the actual response message without further processing.

If you provide an extra parameter to the method, you should use it between curly braces in the URL to make it a URL parameter. For example: /api/users/{userId}.

Constructors

DeleteAttribute(String)

Initializes a new instance of the DeleteAttribute class.

Properties

Path

Gets the path of the request.

RequestName

Gets or sets the name to use for this request within telemetry.

Applies to