I'm having trouble understanding the problem here.
- HTTP-triggered Azure Function
- Python runtime
- Testing on localhost with HTTPS (no problem here)
- URL:
https://localhost:5007/api/BARCODE_API - Goal: Check and validate the
typeparameter of the URL- Ensure it is present, a string, etc.
This works:
import azure.functions as func
import logging
def main(req: func.HttpRequest) -> func.HttpResponse:
if req.params.get('type'):
return func.HttpResponse(
"Test SUCCESS",
status_code=200
)
else:
return func.HttpResponse(
"Test FAIL",
status_code=400
)
I can't see why this does NOT work...
import azure.functions as func
import logging
def main(req: func.HttpRequest) -> func.HttpResponse:
def check_type():
try:
if req.params.get('type'):
return func.HttpResponse(
"Test SUCCESS",
status_code=200
)
except:
return func.HttpResponse(
"Test FAIL",
status_code=400
)
check_barcode = check_type()
- I also tried passing
req.params.get('type')to thecheck_type()function, but same error..
Error
Exception: TypeError: unable to encode outgoing TypedData: unsupported type "<class 'azure.functions.http.HttpResponseConverter'>" for Python type "NoneType"
I can't see why this is happening when I send https://localhost:5007/api/BARCODE_API?type=ean13
EDIT 1: Using @MohitC's recommended syntax still causes the error above.
