Last active
April 5, 2016 09:10
-
-
Save Kevin-Bronsdijk/e80f7660f27ea0cce507be5eb7b67311 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"MyData": "Kevin Bronsdijk", | |
} |
This file contains hidden or 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; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
string jsonContent = await req.Content.ReadAsStringAsync(); | |
dynamic data = JsonConvert.DeserializeObject(jsonContent); | |
if (data.MyData == null ) { | |
return req.CreateResponse(HttpStatusCode.BadRequest, new { | |
error = "Input incorrect!" | |
}); | |
} | |
else | |
{ | |
return req.CreateResponse(HttpStatusCode.OK, new { | |
result = $"Complex result {data.MyData}!" | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment