Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:58:51+00:00 2026-06-14T06:58:51+00:00

I am trying to add to an API a DELETE method as follows: if

  • 0

I am trying to add to an API a DELETE method as follows:

if request.method == 'DELETE':

    if request.headers['Content-Type'] == 'application/json':

        try:
            data = json.loads(request.data)
            data_id = data['id']
            db.execute('DELETE FROM places WHERE id=' + data_id)
            db.commit()
            resp = Response({"Delete Success!"}, status=200, mimetype='application/json')
            return resp

        except (ValueError, KeyError, TypeError):
            resp = Response({"JSON Format Error."}, status=400, mimetype='application/json')
            return resp

I am passing the following CURL:

curl -H "Content-type: applicaiton/json" -X DELETE http://localhost:5000/location -d '{"id":3}'

The try except block is failing for some reason. I am unable to detect what the issue is. Any ideas how I can debug this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:58:53+00:00Added an answer on June 14, 2026 at 6:58 am

    If you change

    except (ValueError, KeyError, TypeError):
        resp = Response({"JSON Format Error."}, status=400, mimetype='application/json')
        return resp
    

    to

    except (ValueError, KeyError, TypeError) as error:
        print error
        resp = Response({"JSON Format Error."}, status=400, mimetype='application/json')
        return resp
    

    you will be able to see your error.

    UPDATE: I’m glad you found your error! I think most modules that wrap database connections allow you to do something like:

    db.execute('SELECT * FROM awesome_table WHERE id=%s', data_id)
    

    and they will typically offer some basic SQL injection protection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I am trying to retreve data from server using api.Since I
I am trying to add the ScannerKit API to my application i have added
I am trying to add my Facebook application through an api. I used http://www.facebook.com/add.php?api_key=xxx&pages=1&page=xxx
I have been trying to use the comments.add REST api method to add comments
Im trying to add new task to asana using asana api. Im using Json.net
I'm trying to add a public API to my app to allow users to
I'm trying to add a field to the List provided by the Spotify API.
I am trying to use the Google Map API- I've successfully managed to add
I'm trying add data triggers to the default combobox style so each text item
Trying to add init parameter names to a list in init(ServletConfig) method. public void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.