简体   繁体   中英

AttributeError: 'tuple' object has no attribute 'get' while using POST request in Postman

I'm trying to use request.get_json() to add nodes from JSON data to a set.

@app.route('/connect_node', methods = ['POST'])

def connect_node():
    json = request.get_json()
    nodes = json.get('nodes')              
    if nodes is None:
        return "No node", 400 

The snapshot of the Postman POST request

The error I'm getting in Spyder(Python 3.9):

line 178, in connect_node
nodes = json.get(nodes)
AttributeError: 'tuple' object has no attribute 'get' 

I'm assuming your going though the udemy blockchain course, turns out its just a problem with the postman check this out Flask app request.get_json() return (Ellipsis, Ellipsis) instead of json

If you are using python 3.9 and getting this error then Build a virtual environment in anaconda with python 3.6 and use this python interpreter for all Spyder consoles. It worked in my case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM