How to send POST request to API using APP INVENTOR?

129 views Asked by At

I'm trying to sent a POST-Request, with App Inventor on a button click to my python program, in that case to log in my app. But I always get code 403 and don't know why. To host the API I'm using Django.

That's the App Inventor Code for my APP:

App Inventor Code1

And that's my current python code, so for example I want to get the api_key, using request.POST['api_key]:

Python Code

And that's finally the log, in this case I'm using the Django testserver with anaconda (pip):

Logfile Console

That're every combination from code I tried, but nothing worked.

AppInventor Code2

AppInventor Code3

I searched even on Stack Overflow, Google or AppInventor itself, but there wasn't any solution for my problem.

1

There are 1 answers

0
Moritz Deinzer On

I proofed it and found the mistake. The problem was the missing csrf_token. I only added

from django.http import JsonResponse 
from django.views.decorators.csrf import csrf_exempt 
from django.views.decorators.http import require_POST 
import json 

@csrf_exempt 
@require_POST 

def xxx():

and it works perfectly.