I am defining an API call on button action (refer to the attached image) in FlutterFlow.
The thing is in the API call, JSON variables are going empty.
I am also attaching the action related to textbox onChange.
The application can be run here
I have defined the backend API as follows:
`@api_view(['POST']) def login_member(request): data = request.body
# Decode the bytes into a string
data_str = data.decode('utf-8')
#splitlist = str(data).split('&')
#username_raw = splitlist[0].split('=')[1]
#password_raw = splitlist[1].split('=')[1]
data_dict = json.loads(data_str)
#parsed_body = QueryDict(data.decode('utf-8'))
#print("Parsed body in login_members is ",parsed_body)
username = data_dict['username']
password = data_dict['password']
print("Username final is ",username)
print("Password final is ",password)
if username == '' or username == None or password == '' or \
password == None or ((username == '' or username == None) and \
(password == '' or password == None)):
return Response(status=status.HTTP_400_BAD_REQUEST)
res = requests.post("http://localhost:8000/token/", data=
{
'username': username,
'password': password
})
return Response(data=res.json())`
I would really appreciate it if anyone is able to help and let me know the solution to the issue
I tried changing the body of API call from Form-encoded to JSON.
I changed my backend settings in python.