GetAttribute Class
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.
Defines an API GET
method.
public ref class GetAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class GetAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type GetAttribute = class
inherit Attribute
Public NotInheritable Class GetAttribute
Inherits Attribute
- Inheritance
- Attributes
[AutoClient("MyClient")]
interface IMyDependencyClient
{
[Get("/api/users/{userId}")]
Task<User> GetUserAsync(string userId, [Query] string filter, CancellationToken cancellationToken);
}
Marks a method within an interface annotated with AutoClientAttribute as an API GET
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 an URL parameter. For example: /api/users/{userId}
.
Get |
Initializes a new instance of the GetAttribute class. |
Path |
Gets the path of the request. |
Request |
Gets or sets the name to use for this request within telemetry. |
Proizvod | Verzije |
---|---|
.NET | 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided) |
Povratne informacije o proizvodu .NET
.NET je projekt otvorenog koda. Odaberite vezu za slanje povratnih informacija: