Created
November 8, 2018 06:45
-
-
Save gscales/cf851dcd9854f523045e1dd8dbe73689 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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