Delphi Rest Request gets Bad request returned -
i have delphi program calling python rest service.
the python rest service looks :
@app.route('/flagger/api/v1.0/stem', methods=['get']) def stem_request(): print request.json if not request.json or u'text' not in request.json: bad_request('no "text" field given') text = request.json['text'] return jsonify(stemmed=stem(text)), 200
when curl request service answer:
c:\program files\curl>curl -i -h "content-type: application/json" -x -d "{\"text\":\"hij geeft mij appels\"}" h ttp://192.168.99.100:5000/flagger/api/v1.0/stem http/1.0 200 ok content-type: application/json content-length: 30 server: werkzeug/0.11.3 python/2.7.10 date: thu, 28 jan 2016 13:17:36 gmt { "stemmed": "geeft appel" }
in delphi xe7/pro program have restclient, restrequest , restresponse component.
all components have contentype=application/json
restrequest.method=rmget
to restrequest added parameter :
contenttype=ctapplication_json kind=pkrequestbody name=text value=hij geeft mij appels.
the request started following code:
memocontent.lines.add('start...'); restclient1.baseurl:='http://192.168.99.100:5000/flagger/api/v1.0/stem'; memocontent.lines.add('request params.name= '+restrequest1.params.items[0].name); memocontent.lines.add('request params.value= '+restrequest1.params.items[0].value); restrequest1.execute; memocontent.lines.add('status= '+restresponse1.statustext); memocontent.lines.add('content= '+restresponse1.content); memocontent.lines.add('fullrequesturi= '+restresponse1.fullrequesturi); memocontent.lines.add('baseurl= '+restclient1.baseurl); jvalue:=restresponse1.jsonvalue; memocontent.lines.add('response json= '+jvalue.tostring); memocontent.lines.add('statustext= '+restresponse1.statustext);
the request executed bad request answer:
start... request params.name= text request params.value= dit een test status= http/1.0 400 bad request content= { "error": "bad request" } fullrequesturi= http://192.168.99.100:5000/flagger/api/v1.0/stem baseurl= http://192.168.99.100:5000/flagger/api/v1.0/stem response json= {"error":"bad request"} statustext= http/1.0 400 bad request
anyone has idea what's wrong here ?
i can't make work rest debugger either works curl , other rest clients
thanks.
Comments
Post a Comment