From f6bdedbaa41fd28ac8ba2a615cdab606c35bc441 Mon Sep 17 00:00:00 2001 From: Winona Azure <38537084+wiazur@users.noreply.github.com> Date: Wed, 26 Sep 2018 15:37:08 -0700 Subject: [PATCH] Changed HttpRequestMessage to HttpRequest The VS version is now not running without this change. However, it does not post to the SQL database in Azure. Might take time to fix. In the meantime, this modified sample will at least run the Http calls in Visual Studio, successfully. I will update the readme. --- examples/azure-function-endpoint/run.csx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/azure-function-endpoint/run.csx b/examples/azure-function-endpoint/run.csx index bd0aac5..b9b7016 100644 --- a/examples/azure-function-endpoint/run.csx +++ b/examples/azure-function-endpoint/run.csx @@ -2,16 +2,18 @@ #r "System.Net.Http" using System; +using System.IO; using System.Text; using System.Data; using System.Data.SqlClient; using System.Net; using System.Net.Http; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; static HttpClient httpClient = new HttpClient(); -public static async Task Run(HttpRequestMessage req, ILogger log) +public static async Task Run(HttpRequest req, ILogger log) { // The Application ID from any published app in luis.ai, found in Manage > Application Information var LUISappID = "YOUR_APP_ID"; @@ -26,12 +28,10 @@ public static async Task Run(HttpRequestMessage req, ILogge log.LogInformation("Get LUIS query from HTTP Request"); // Query string - string query = req.GetQueryNameValuePairs() - .FirstOrDefault(q => string.Compare(q.Key, "query", true) == 0) - .Value; + string query = req.Query["query"]; // POST Body - dynamic data = await req.Content.ReadAsAsync(); + dynamic data = await new StreamReader(req.Body).ReadToEndAsync(); // Final LUIS Query query = query ?? data?.query;