Running into an issue where I can't send a request from my Android Emulator to my locally running Azure API. I keep getting a 400 error(Bad Request). Below is the sample request I'm sending. I can successfully reach my local Azure Api through postman. I have attached the code for the request and for the azure function below. Also I have set my permissions for my android project for android.permission.INTERNET
Android Get Request
@Headers(
"Accept-Encoding: chunked",
"Content-Type: Application/Json;charset=UTF-8",
"Accept: Application/Json",
"Server: Microsoft-HTTPAPI/2.0"
)
suspend fun getLabel(
@Path("labelId") labelId: Int
): LabelTag
Azure Function
[FunctionName("GetLabel")]
public static async Task<HttpResponseMessage> GetLabel([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "label/{labelId}")]HttpRequestMessage req, int labelId, TraceWriter log)
{
HttpResponseMessage response;
try
{
LabelService labelLogic = new LabelService();
log.Info("Retrieving from database");
var label = labelLogic.GetLabelById(labelId);
if (label != null)
{
log.Info("Retrieved from database");
response = req.CreateResponse(HttpStatusCode.OK, label);
}
else
{
var errorMessage = "Failed to retrieve label";
log.Error(errorMessage);
response = req.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage);
}
}
catch (Exception e)
{
log.Error(e.Message, e);
response = req.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
}
return response;
}