in Education by
URL is http://*.*.*.*/100/?id=1&version=1 params is {"cityId": "110000", "query": {"queryStr": "line1", "queryExp": ""}, "channelId": "house"} curl command is: curl -X POST -H "Content-Type: application/json" -d '{"cityId": "110000", "query": {"queryStr": "line1", "queryExp": ""}, "channelId": "house"}' "http://*.*.*.*/100/?id=1&version=1" but when I use tornado(4.2) AsyncHTTPClient, I got error: tornado.application:Future exception was never retrieved: Traceback (most recent call last): ... HTTPError: HTTP 500: Internal Server Error I request like this: @gen.coroutine def request(self, url, method="GET", headers=None, data=None): logger.debug(method) logger.debug(headers) logger.debug(data) headers = { 'content-type': 'application/json', } req = HTTPRequest( url, method=method, headers=headers, body=urllib.urlencode(data).encode('utf-8') ) http_response = yield self.r.fetch( # req, # self.handle_request url, method=method, headers=headers, body=urllib.urlencode(data).encode('utf-8') ) # logger.debug(http_response) raise gen.Return(json.loads(http_response.body)) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You're sending 'content-type': 'application/json', but encoding the data with body=urllib.urlencode(data).encode('utf-8'). Use json.dumps instead of urllib.urlencode.

Related questions

0 votes
    This question already has answers here: asynchronous python itertools chain multiple generators (2 answers) Closed 2 ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I want to execute a curl command in Python. Usually, I just need to enter the command in the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I want to execute a curl command in python. curl -d @request.json --header "Content-Type: application/json" https: ... Help me fix it. Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    This is a cURL function that can send or retrieve data. It should work with any PHP app that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    How can we POST JSON data with cURL?...
asked Jan 11, 2021 in Technology by JackTerrance
0 votes
    This is my code it's just starting the scan but it is not completing ,where is the error in it. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    For example I have this 1 ['cancelled:', '7'] And I want to split to only get the integer value ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    For example I have this 1 ['cancelled:', '7'] And I want to split to only get the integer value ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I am totally new to Machine Learning and I have been working with unsupervised learning technique. Image shows my ... 3 were given Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I know a little of Python and more than a year ago I wrote a small script, using pipenv to manage the ... 3.0 should work. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I am trying to make an app that can get the patient's symptoms as inputs and outputs the three most likely ... classes[sortedshit[2]]) Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    If I use a while loop for my below code, it is not giving the desired output, but when i use for loop i am anle ... x += 1 print(Comm) Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    I have three columns like follows: Sales Population Income Price 14 48777.0 285.0 nan 17 12550.0 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm trying to install some machine learning libraries on a new Windows laptop (I usually have Mac laptops ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I'm trying to install some machine learning libraries on a new Windows laptop (I usually have Mac laptops ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
...