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.
This commit is contained in:
Родитель
7413d44362
Коммит
f6bdedbaa4
|
@ -2,16 +2,18 @@
|
||||||
#r "System.Net.Http"
|
#r "System.Net.Http"
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
static HttpClient httpClient = new HttpClient();
|
static HttpClient httpClient = new HttpClient();
|
||||||
|
|
||||||
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, ILogger log)
|
public static async Task<HttpResponseMessage> Run(HttpRequest req, ILogger log)
|
||||||
{
|
{
|
||||||
// The Application ID from any published app in luis.ai, found in Manage > Application Information
|
// The Application ID from any published app in luis.ai, found in Manage > Application Information
|
||||||
var LUISappID = "YOUR_APP_ID";
|
var LUISappID = "YOUR_APP_ID";
|
||||||
|
@ -26,12 +28,10 @@ public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, ILogge
|
||||||
log.LogInformation("Get LUIS query from HTTP Request");
|
log.LogInformation("Get LUIS query from HTTP Request");
|
||||||
|
|
||||||
// Query string
|
// Query string
|
||||||
string query = req.GetQueryNameValuePairs()
|
string query = req.Query["query"];
|
||||||
.FirstOrDefault(q => string.Compare(q.Key, "query", true) == 0)
|
|
||||||
.Value;
|
|
||||||
|
|
||||||
// POST Body
|
// POST Body
|
||||||
dynamic data = await req.Content.ReadAsAsync<object>();
|
dynamic data = await new StreamReader(req.Body).ReadToEndAsync();
|
||||||
|
|
||||||
// Final LUIS Query
|
// Final LUIS Query
|
||||||
query = query ?? data?.query;
|
query = query ?? data?.query;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче