-1

I have response object as <Request 'http://xx.xx.xx.xx/pipelineInfo' [GET]>and i am trying to get data from the request object as

request.json.get('xxx',NONE)

and also as

request.get('XXX',NONE) 

but failed to get a response and getting an error as

Exception : 'Request' object has no attribute 'get' and Exception : 'Request' object has no attribute 'json'.

Can someone suggest me what the issue will be?

Sowmya Vejerla
  • 93
  • 1
  • 15

2 Answers2

0

you need use args property reqcontext

request.args.get('XXX')

or get_json

request.get_json().get('XXX')
Brown Bear
  • 19,655
  • 10
  • 58
  • 76
0

If the data sent in the request is json, you can use json_data = request.get_json() However,this function will return None if the mimetype is not application/json, but this can be overridden by the force parameter.

json_data = request.get_json(force=True)

An alternative way to get json data is:

json_data = json.loads(request.data) as well.

Other ways of getting data from request can be found in this question: How to get data received in Flask request

Also, please do have a look at official documentation(http://flask.pocoo.org/docs/0.12/api/#flask.Request.get_json)

Tevin Joseph K O
  • 2,574
  • 22
  • 24