hug icon indicating copy to clipboard operation
hug copied to clipboard

Fetching GET request parameters from Java to Python Hug REST API

Open jacob7182 opened this issue 8 years ago • 1 comments

I have created a Rest API using Python Hug which accepts a list as a parameter.

import hug
@hug.get('/myFunc/')
def myFunc(textList)
   print(len(textList))
   print(type(textList))

I am calling the REST API from Java application. The application is passing a Java arrayList to the python API. The size of arrayList is 17. When the Python REST API is called, and I print the length of list on python side, the length of list items is not the same, it is somewhere around 500. Is this due to sending the parameter as a query string in the GET request or is there a conversion issue between Java arrayList and Python List used through Hug Rest API?

jacob7182 avatar Aug 28 '18 14:08 jacob7182

the issue has been resolved, by making the api as a POST method, passing the value from Java as request body and fetching the input as body on Python side.

import hug
@hug.post('/myFunc/')
def myFunc(body)
   textList = body['textList']

jacob7182 avatar Aug 28 '18 16:08 jacob7182