Skip to content

Instantly share code, notes, and snippets.

@jeffhollan
Created May 25, 2016 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffhollan/76eab2341be739ea92c3d84db61dd09a to your computer and use it in GitHub Desktop.
Save jeffhollan/76eab2341be739ea92c3d84db61dd09a to your computer and use it in GitHub Desktop.
#r "Newtonsoft.Json"
using System;
using System.Net;
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);
string msgBody = data.body;
log.Verbose($"Message Received: {msgBody}");
int length = msgBody.Length;
log.Verbose($"Message Length: {length.ToString()}");
int start = msgBody.IndexOf("{");
string result = msgBody.Substring(start, length - start);
return req.CreateResponse(HttpStatusCode.OK, JsonConvert.DeserializeObject(result));
}
@jeffhollan
Copy link
Author

Would call this function from a Logic app with the object:

{
"body": "@\u0006string\b3http://schemas.microsoft.com/2003/10/Serialization/�H{\"heartbeatprocessed\":0,\"time\":\"2016-04-12T03:42:18.0000000Z\",\"count\":1}"
}

or

{
"body": "[Content]"
}

Where [Content] is my service bus token in the designer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment