Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#r "Newtonsoft.Json"
using System;
using System.Net;
using System.Threading.Tasks;
using Newtonsoft.Json;
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
{
log.Verbose($"Webhook was triggered!");
string jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
if (data.first == null || data.last == null) {
return req.CreateResponse(HttpStatusCode.BadRequest, new {
error = "Please pass first/last properties in the input object"
});
}
var extensionMethodTest = Enumerable.Range(1, 11).Select(x => x * 10).ToArray().ToJoinedString(",");
return req.CreateResponse(HttpStatusCode.OK, new {
greeting = $"Hello {data.first} {data.last} and {extensionMethodTest}!"
});
}
public static string ToJoinedString<T>(this IEnumerable<T> source, string separator = "")
{
return string.Join(separator, source);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment