Created
April 5, 2016 08:47
-
-
Save Kevin-Bronsdijk/c88f826b0d26939c1cd86d707303133b 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