First time posting. How do I load data from a third party database that has its own API (REST API) which has an API Search Endpoint to implement with my azure web app bot? All I need is to get the search functionality from the database (users type in queries in the search bar of a third party website and the relevant results are displayed to the user by extracting data from the database that the website uses to get information from.) I need to implement this search functionality with my azure webapp bot which is developed in C#. Currently my web bot used the QnA maker as well.
Would really appreciate any feedback.
You might have a look at this documentation: https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client
The example in that document instantiates an HTTP client object like this, though it's up to you if you want to use static
or any other modifiers on the field you declare:
static HttpClient client = new HttpClient();
You can see that the HTTP client is used for GET requests like this:
static async Task<Product> GetProductAsync(string path)
{
Product product = null;
HttpResponseMessage response = await client.GetAsync(path);
if (response.IsSuccessStatusCode)
{
product = await response.Content.ReadAsAsync<Product>();
}
return product;
}
The important parts there are client.GetAsync
and response.Content.ReadAsAsync
.
This is a fairly minimal example that doesn't include things like authorization headers and such. You can have a look at the Microsoft.Bot.Connector namespace and especially Conversations.cs for more advanced examples of HTTP requests.