Dheeraj Kumar
Dheeraj Kumar

Reputation: 408

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

I was trying to test Transactions via Playground, Composer-Rest-server and Finally POSTMAN.

The Transactions worked perfectly on Playground (Figure 1 and 2) and also on the Composer-Rest-Server (Figure 3 and 4). But then I tried the same using POSTMAN, for which I am getting an Error ( Status Code 422 )(Figure 5).

I'm using the basic-sample-network. And the Transaction just updates the value of the asset.

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

The Error

"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 ...

What is the reason for this Error and How can I solve it?

Upvotes: 0

Views: 1540

Answers (1)

Isha Padalia
Isha Padalia

Reputation: 1222

You have to post data in JSON format.

enter image description here

Upvotes: 1

Related Questions