1

I am having path "/todo/{id}", I want to get the Id path param.

        [Function("Run")]
        public static HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get",
            Route = "todo/{id}")] HttpRequestData req,
            FunctionContext executionContext)
        {
            var logger = executionContext.GetLogger("GetTodo");
            logger.LogInformation("C# HTTP trigger function processed a request.");

            var response = req.CreateResponse(HttpStatusCode.OK);
            response.Headers.Add("Content-Type", "text/plain; charset=utf-8");

            response.WriteString("Welcome to Azure Functions!");

            return response;
        }

How can I get access to Id?

Thanks in advance!

chiaDev
  • 389
  • 3
  • 17

1 Answers1

2

Binding inputs can be included.

You can get path param by placing variables in the method parameter.

        [Function("Run")]
        public static HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get",
            Route = "todo/{id}")] HttpRequestData req, string id,
            FunctionContext executionContext) 
{
            var logger = executionContext.GetLogger("GetTodo");
            logger.LogInformation("C# HTTP trigger function processed a request.");

            logger.LogInformation("This is the id - {id}", id);
}
chiaDev
  • 389
  • 3
  • 17