Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curl success, but Internal Server Error when commit transaction #501

Open
leejie8008 opened this issue Jul 24, 2019 · 3 comments
Open

Curl success, but Internal Server Error when commit transaction #501

leejie8008 opened this issue Jul 24, 2019 · 3 comments

Comments

@leejie8008
Copy link

  • bigchaindb-driver version: 0.6.2
  • bigchaindb version: 2.0.0b9
  • Python version: 3.6.8
  • Operating System: Virtual machine of Ubuntu 16, through Window 10 host

Description

I set up bigchaindb, with python driver and mongodb. Then, I try to run the code from Basic Usage Example, and receive Internal Server Error, but when I run curl http://localhost:9984/api/v1/transactions, it shows {"message": {"asset_id": "Missing required parameter in the JSON body or the post body or the query string"}}, which means that my connection is established.

How can I debug form here?

What I Did

from bigchaindb_driver import BigchainDB
from bigchaindb_driver.crypto import generate_keypair
from time import sleep
from sys import exit

bdb_root_url = 'localhost:9984'
# bdb_root_url = 'http://127.0.0.1:9984'
bdb = BigchainDB(bdb_root_url)

bicycle_asset = {
    'data': {
        'bicycle': {
            'serial_number': 'abcd1234',
            'manufacturer': 'bkfab'
        },
    },
}

bicycle_asset_metadata = {
    'planet': 'earth'
}

alice, bob = generate_keypair(), generate_keypair()

prepared_creation_tx = bdb.transactions.prepare(
    operation='CREATE',
    signers=alice.public_key,
    asset=bicycle_asset,
    metadata=bicycle_asset_metadata
)

fulfilled_creation_tx = bdb.transactions.fulfill(
    prepared_creation_tx,
    private_keys=alice.private_key
)

sent_creation_tx = bdb.transactions.send_commit(fulfilled_creation_tx)

txid = fulfilled_creation_tx['id']

print("tid: " + txid)

asset_id = txid

transfer_asset = {
    'id': asset_id
}

output_index = 0
output = fulfilled_creation_tx['outputs'][output_index]

transfer_input = {
    'fulfillment': output['condition']['details'],
    'fulfills': {
        'output_index': output_index,
        'transaction_id': fulfilled_creation_tx['id']
    },
    'owners_before': output['public_keys']
}

prepared_transfer_tx = bdb.transactions.prepare(
    operation='TRANSFER',
    asset=transfer_asset,
    inputs=transfer_input,
    recipients=bob.public_key,
)

fulfilled_transfer_tx = bdb.transactions.fulfill(
    prepared_transfer_tx,
    private_keys=alice.private_key,
)

sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)

print("Is Bob the owner?",
    sent_transfer_tx['outputs'][0]['public_keys'][0] == bob.public_key)

print("Was Alice the previous owner?",
    fulfilled_transfer_tx['inputs'][0]['owners_before'][0] == alice.public_key)

My stacktrace

vagrant@ubuntu-bionic:/vagrant$ python3 main.py
Traceback (most recent call last):
  File "main.py", line 79, in <module>
    sent_creation_tx = bdb.transactions.send_commit(fulfilled_creation_tx)
  File "/usr/local/lib/python3.6/dist-packages/bigchaindb_driver/driver.py", line 375, in send_commit
    headers=headers)
  File "/usr/local/lib/python3.6/dist-packages/bigchaindb_driver/transport.py", line 82, in forward_request
    backoff_cap=backoff_cap,
  File "/usr/local/lib/python3.6/dist-packages/bigchaindb_driver/connection.py", line 91, in request
    **kwargs,
  File "/usr/local/lib/python3.6/dist-packages/bigchaindb_driver/connection.py", line 128, in _request
    raise exc_cls(response.status_code, text, json, kwargs['url'])
bigchaindb_driver.exceptions.TransportError: (500, '{"message": "Internal Server Error"}\n', {'message': 'Internal Server Error'}, 'http://localhost:9984/api/v1/transactions/')

vagrant@ubuntu-bionic:/vagrant$ curl http://localhost:9984
{"api":{"v1":{"assets":"/api/v1/assets/","blocks":"/api/v1/blocks/","docs":"https://docs.bigchaindb.com/projects/server/en/v2.0.0b9/http-client-server-api.html","metadata":"/api/v1/metadata/","outputs":"/api/v1/outputs/","streams":"ws://localhost:9985/api/v1/streams/valid_transactions","transactions":"/api/v1/transactions/","validators":"/api/v1/validators"}},"docs":"https://docs.bigchaindb.com/projects/server/en/v2.0.0b9/","software":"BigchainDB","version":"2.0.0b9"}

vagrant@ubuntu-bionic:/vagrant$ curl http://localhost:9984/api/v1/transactions
{"message": {"asset_id": "Missing required parameter in the JSON body or the post body or the query string"}}
@LuffySmile
Copy link

I have the same problem. Have you solved it now?

@xiaowei6688
Copy link

@LuffySmile Have you solved it

@Yehezkiel-simbuang
Copy link

@LuffySmile @xiaowei6688 Have you solve it? I have same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants