mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Use more common X-Api-Key header with no prefix Also updates Unauthorized response to include a json error body and simplifies working with new API key via curl and the vscode rest client Signed-off-by: James Taylor <jamest@uk.ibm.com>
84 lines
1.5 KiB
HTTP
84 lines
1.5 KiB
HTTP
// Demo file for use with REST Client for Visual Studio Code
|
|
// See https://github.com/Huachao/vscode-restclient
|
|
//
|
|
// Edit the values below to match your environment if required
|
|
@hostname = localhost
|
|
@port = {{$dotenv PORT}}
|
|
@baseUrl = http://{{hostname}}:{{port}}
|
|
@apiUrl = {{baseUrl}}/api
|
|
@api-key = {{$dotenv ORG1_APIKEY}}
|
|
|
|
### Check the server is ready
|
|
|
|
GET {{baseUrl}}/ready HTTP/1.1
|
|
|
|
### Check the server is still live
|
|
|
|
GET {{baseUrl}}/live HTTP/1.1
|
|
|
|
### Get all assets
|
|
|
|
GET {{apiUrl}}/assets HTTP/1.1
|
|
X-Api-Key: {{api-key}}
|
|
|
|
### Check if asset exists
|
|
|
|
OPTIONS {{apiUrl}}/assets/asset7 HTTP/1.1
|
|
X-Api-Key: {{api-key}}
|
|
|
|
### Create asset
|
|
|
|
POST {{apiUrl}}/assets HTTP/1.1
|
|
content-type: application/json
|
|
X-Api-Key: {{api-key}}
|
|
|
|
{
|
|
"id": "asset7",
|
|
"color": "red",
|
|
"size": 42,
|
|
"owner": "Jean",
|
|
"appraisedValue": 101
|
|
}
|
|
|
|
### Read transaction status
|
|
|
|
GET {{apiUrl}}/transactions/__transaction_id__ HTTP/1.1
|
|
X-Api-Key: {{api-key}}
|
|
|
|
### Read asset
|
|
|
|
GET {{apiUrl}}/assets/asset7 HTTP/1.1
|
|
X-Api-Key: {{api-key}}
|
|
|
|
### Update asset
|
|
|
|
PUT {{apiUrl}}/assets/asset7 HTTP/1.1
|
|
content-type: application/json
|
|
X-Api-Key: {{api-key}}
|
|
|
|
{
|
|
"id": "asset7",
|
|
"color": "red",
|
|
"size": 11,
|
|
"owner": "Jean",
|
|
"appraisedValue": 101
|
|
}
|
|
|
|
### Transfer asset
|
|
|
|
PATCH {{apiUrl}}/assets/asset7 HTTP/1.1
|
|
content-type: application/json
|
|
X-Api-Key: {{api-key}}
|
|
|
|
[
|
|
{
|
|
"op": "replace",
|
|
"path": "/owner",
|
|
"value": "Ashleigh"
|
|
}
|
|
]
|
|
|
|
### Delete asset
|
|
|
|
DELETE {{apiUrl}}/assets/asset7 HTTP/1.1
|
|
X-Api-Key: {{api-key}}
|