Hello @ankit kumar I tried your code. I am sharing my code :
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using System.Text;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
var hash = Convert.FromBase64String( name );
var sb = new StringBuilder();
foreach( var b in hash )
{
sb.Append( b.ToString("X2") );
}
string str = sb.ToString();
return str != null
? (ActionResult)new OkObjectResult(str)
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
Couple of changes made. I have added using System.Text;
for the StringBuilder and modified the return object.
Output :
Please confirm if this helps. If yes, then please "accept the answer" and "up-vote" so that it help others in the community.