Skip to content

Instantly share code, notes, and snippets.

@gscales
Created November 8, 2018 06:45
Show Gist options
  • Save gscales/cf851dcd9854f523045e1dd8dbe73689 to your computer and use it in GitHub Desktop.
Save gscales/cf851dcd9854f523045e1dd8dbe73689 to your computer and use it in GitHub Desktop.
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string RunBookWebHook = "https://s8events.azure-automation.net/webhooks?to......";
bool test = false;
if(req.Query.ContainsKey("validationToken")){
return new OkObjectResult(req.Query["validationToken"].ToString());
}else{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
var requestData = new StringContent(requestBody, Encoding.UTF8, "application/json");
using (var client = new HttpClient())
{
var response = await client.PostAsync(String.Format(RunBookWebHook), requestData);
var result = await response.Content.ReadAsStringAsync();
}
return new OkObjectResult("No-validationToken");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment