HTTP Body

{
  "name": "John Doe"
}

Code

#r "Newtonsoft.Json"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;

public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
    string name = "";

    string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
    dynamic data = JsonConvert.DeserializeObject(requestBody);
    name = data.name;

    string responseMessage = "Hello, " + name;

            return new OkObjectResult(responseMessage);
}

Result (HTTP POST)


Hello, John Doe

Last modified: March 26, 2021

Author

Comments

Write a Reply or Comment