Problem about Postman for Deleting with Flask Python
06:06 05 Sep 2022

I have a simple FLASK-API which is related to authentication, I mean by simple log-in, register page. For the test by backend I use Postman, I also use MySQL for the database. When I am giving ID input from Postman for the delete user, I got an error message. I am dropping my delete route below.

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

def delete():

message=''

cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)

if request.method == 'POST': 
    for id in request.json.getlist('mycheckbox'):
        print(id)
        cursor.execute('DELETE FROM usertable WHERE id = {0}'.format(id))
        mysql.connection.commit()
    message='Successfully Deleted!'
return jsonify(message)

I have also log in and register routes, I use POST methods in Postman, and It works well, when I enter the e-mail, username, and password, It gives me jsonify message in postman like "you have successfully logged in, etc. However, if I want to delete a user by giving an ID only

{

"id": "18"

}

I got this message;

500 Internal Server Error, The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

flask postman