尝试使用 POSTMAN POST REST API 上的 Hyperledger 事务时出现验证错误(错误代码 422)

Validation Error (Error Code 422) while trying to POST Hyperledger Transaction on REST API using POSTMAN

我试图通过 Playground、Composer-Rest-server 和 Finally POSTMAN 测试交易。

事务在 Playground(图 1 和 2)以及 Composer-Rest-Server(图 3 和 4)上运行良好。但是后来我尝试使用 POSTMAN 进行相同的操作,但我收到错误(状态代码 422)(图 5)。

我正在使用 basic-sample-network。而交易只是更新资产的价值。

Figure 1 - Executing Sample Transaction On Playground

Figure 2 - Updated Value of Asset #3952

Figure 3 - Executing the Transaction on the composer Rest Server

Figure 4 - Updated Value of Asset #3952 after the Rest Server Transaction

Figure 5 - Error While Using POSTMAN

错误

"error": {
    "statusCode": 422,
    "name": "ValidationError",
    "message": "The `org_example_basic_SampleTransaction` instance is not valid. Details: `asset` can't be blank (value: undefined); `newValue` can't be blank (value: undefined).",
    "details": {
        "context": "org_example_basic_SampleTransaction",
        "codes": {
            "asset": [
                "presence"
            ],
            "newValue": [
                "presence"
            ]
        },
        "messages": {
            "asset": [
                "can't be blank"
            ],
            "newValue": [
                "can't be blank"
            ]
        }
    },
    "stack": "ValidationError: The `org_example_basic_SampleTransaction` instance is not valid. Details: `asset` can't be blank (value: undefined); `newValue` can't be blank (value: undefined).\n    at ...

出现此错误的原因是什么,我该如何解决?

您必须 post 数据 JSON 格式。