Get data from a http request, in a function app.
How is it possible?
This is the link to the official documentation https://docs.microsoft.com/en-us/python/api/azure-functions/azure.functions.httprequest?view=azure-python .
We prefer to set down some notes, anyway.
“`def main(request: func.HttpRequest): “`
so, you can access, the request data (mind that often the request is shoted in req):
- request method with request.method (like ‘OPTIONS’)
request header with request.headers.get, for instance(‘Access-Control-Allow-Origin’), ‘*’, ‘http response header allow origin’)
request.headers.get(‘Access-Control-Allow-Origin’), ‘*’, ‘http response header allow origin’)
the body = request.get_json(). Simply that: this command already returns a dictionary! I.e. body == dictionary