次の方法で共有


ConfidentialLedgerClient.GetTransactionStatusAsync メソッド

定義

[プロトコルメソッド]トランザクション ID で識別されるエントリの状態を取得します。

  • この プロトコル メソッド を使用すると、高度なシナリオで応答の要求と処理を明示的に作成できます。
public virtual System.Threading.Tasks.Task<Azure.Response> GetTransactionStatusAsync (string transactionId, Azure.RequestContext context = default);
abstract member GetTransactionStatusAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetTransactionStatusAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetTransactionStatusAsync (transactionId As String, Optional context As RequestContext = Nothing) As Task(Of Response)

パラメーター

transactionId
String

書き込みトランザクションを識別します。

context
RequestContext

要求コンテキスト。これは、クライアント パイプラインの既定の動作を呼び出しごとにオーバーライドできます。

戻り値

サービスから返された応答。

例外

transactionId が null です。

transactionId は空の文字列であり、空でないと予想されていました。

サービスから成功以外の状態コードが返されました。

このサンプルでは、必要なパラメーターを使用して GetTransactionStatusAsync を呼び出し、結果を解析する方法を示します。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);

Response response = await client.GetTransactionStatusAsync("<transactionId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("transactionId").ToString());

注釈

応答ペイロードの JSON スキーマを次に示します。

応答本文:

TransactionStatusスキーマ:

{
  state: "Committed" | "Pending", # Required. Represents the state of the transaction.
  transactionId: string, # Required. A unique identifier for the state of the ledger. If returned as part of a LedgerEntry, it indicates the state from which the entry was read.
}

適用対象