All Products
Document Center

Invoke Transaction to Query Data

Last Updated: Apr 03, 2020

Invoke the smart contract to query the data in the blockchain network.


POST /api/v1/networks/{network}/transactions/query

Url Path Args Description
network Fabric channel name

Request Parameter

URL Query

URL Query Args Type Required Description
timeout Integer False Maximum wait time in seconds to confirm whether submitted transaction is success(valid) or not. Default is 180.


Content-Type: application/json

Name Type Required Description
chaincode String True The Name of target smart contract
args List<String> False The arguments list of the smart contract call. When this parameter(args) is not empty, the function and byte_args parameters are ignored.
function String False The name of smart contract function to call
byte_args List<String> False Base64-encoded smart contract call arguments (without function name)
transient Map<String, String> False The transient map of this call, Key is the name, and Value is data
byte_transient Map<String, String> False The transient map of this call, Key is the name, and Value is base64-encoded data(this parameter will merge with transient and overrides the Key in it)


Name Type Description
Success Boolean Indicating if the request was successful.
Error Error -
Result Response -


Name Type Description
code Integer Error code
message String Error description
request_id String The id of this request


Name Type Description
id String Transaction ID
status String Status code returned by smart contract
event List<Event> List of blockchain events generated by the transaction
data String Base64-encoded data returned by smart contract


Name Type Description
id String Event ID, unique within the channel
name String Event name
type EventType Event type(“Tx”, “Config”, “Contract”, “Block”), here is always “Contract”
content String When EventType is “Contract”, it is Base64 encoded event content


Request Example

  1. curl -X POST "http://your.gateway.endpoint/api/v1/networks/channel3/transactions/query" -H "accept: application/json" -H "Authorization: Bearer <Your Access Token>" -H "Content-Type: application/json" -d "{\"chaincode\":\"sacc\",\"args\":[\"get\",\"provider\"],\"transients\":{\"key\":\"value\"}}"

Example of Normal Return

  1. {
  2. "Success": true,
  3. "Result": {
  4. "id": "3f850796a57db7178f8e367cce736a228a8e77544ef5c92a564f9cf0ad8893c4",
  5. "status": "200",
  6. "events": [],
  7. "data": "YWxpeXVuMQ=="
  8. },
  9. "Error": {
  10. "code": 200,
  11. "message": "Success",
  12. "request_id": "5640793d-219e-4e2f-9725-988ce11ee6b6"
  13. }
  14. }

Error Code

Please refer to Error Code