Python Forum
Receiving Werkzeug. exception. Bad Request error when using GET with an endpoint
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Receiving Werkzeug. exception. Bad Request error when using GET with an endpoint
#1
Hello,

I was trying to implement an API using Python, and flask to help myself learn and practice REST.

The idea was to receive a HTTP POST with data that looks like as such:
{"startDate":"2015-07-01","endDate":2015-07-08","within":{"value":9000,"units":miles}}

I was able to create a POST method , and I am able to receive the data (both in POSTMAN and in the browser). Here is the relevant code :

@neows.route('/UserInput',methods=['GET','POST'])
def UserInput():
        startDate = request.args.get('startDate')
        endDate = request.args.get('endDate')
        #print (type(startDate))
        #print (type(endDate))
        getAsteroids(startDate,endDate)
        return jsonify(request.args)
But when I use the data provided above to GET some data from a NASA API I am receiving this error: werkzeug.exceptions.BadRequestKeyError

Here is the url I am trying to hit : Nasa Endpoint

I am able to hit the url both on POSTMAN and browser, outside of my code.

Here is the relevant piece of code
def getAsteroids(startDate,endDate):
        API_KEY='8Yrp7t6VDsh5DahF7i1hzLEykr9IHljF8LrZ70RL'
        print (startDate)
        print (endDate)
        [color=#C0392B]result=request.args["https://api.nasa.gov/neo/rest/v1/feed? 
        start_date="+startDate+"&end_date="+endDate+"&api_key="+API_KEY+""][/color]
        	
The line above in red is throwing the error. I would really appreciate if someone could help me understand and resolve the issue.

Thank you
Reply


Messages In This Thread
Receiving Werkzeug. exception. Bad Request error when using GET with an endpoint - by robogeek - Jul-02-2019, 01:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Zeep - BasicHTTPBinding secured Endpoint throws 500-invalid security error vinoth 0 2,103 Jul-15-2021, 03:00 PM
Last Post: vinoth
  concatenate a request to the endpoint of OSM-API?! apollo 0 1,603 Aug-13-2020, 02:45 PM
Last Post: apollo
  How to POST html data to be handled by a route endpoint nikos 1 2,394 Mar-07-2020, 03:14 PM
Last Post: nikos
  Flask Error-Could not build url for endpoint 'index'. Did you forget to specify value Prince_Bhatia 0 10,321 Feb-25-2019, 05:52 AM
Last Post: Prince_Bhatia
  Syntax error for HTTP request GET THX1138 1 6,414 May-12-2018, 12:02 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020