Introduction
The Bing Web Search API provides an experience similar to Bing.com/Search by returning search results that Bing determines are relevant to the user's query. The API results include Web pages, images, videos, news, and entities, along with related search queries, spelling corrections, time zones, unit conversion, translations, and calculations. The web Search API uses JSON format for data exchange and API Keys for authentication.

In this article, I will show how to generate the Bing Search subscription key and integrate it into the Xamarin application.
Register Bing Search on Azure Portal
You need to create an Azure account and generate a subscription key for implementation to the Xamarin Mobile application.
Step 1
Sign in to the Azure portal.
Step 2
Create On “+ Create a resource “> Under Azure Marketplace, select AI + Cognitive Services, and discover the list of available APIs. > Select “ Bing Search v7 APIs”

Step 3
On the create page, provide the name, pricing, resource group and click on Create

Step 4
Wait for a few seconds. After the Cognitive Services account is successfully deployed, click the notification or tile in the dashboard to view the account information. You can copy the Endpoint URL in the Overview section and keys in the Keys section to start making API calls in our Xamarin applications.

Create a Bing Web Search Xamarin Application
Let's start with creating a new Xamarin Forms Project using Visual Studio. Open Run >> Type “Devenev.Exe” and enter >> New Project (Ctrl+Shift+N) >> select Blank XAML App (Xamarin.Forms) template.

It will automatically create multiple projects, like .NET Standard, Android, iOS, and UWP.
Install Newtonsoft.Json
Bing Web Search API will return JSON object value so make sure you have added the Newtonsoft JSON NuGet Package to your all project. Right Click on Solution > Manage Nuget Package > Install Newtonsoft JSON.

Install Microsoft.Csharp
This step is optional. If you get the error "Microsoft.CSharp.RuntimeBinder.Binder.Convert" is not found by the compiler for dynamic type, by adding a reference as Microsoft.CSharp to the Dotnet Standard /PCL project, the issue will get resolved.

Design View
After successfully installing the above two nuget packages, let's start designing the UI design from Dot Standard /PCL project. In PCL Project > Open MainPage.Xaml page and add design Entry and list view control with item template in Xaml
- <?xml version="1.0" encoding="utf-8" ?>
- <ContentPage xmlns="https://xamarin.com/schemas/2014/forms"
- xmlns:x="https://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:local="clr-namespace:XamarinBingWebSearch"
- x:Class="XamarinBingWebSearch.MainPage">
- <ContentPage.Content>
- <StackLayout>
- <Label Text="Search" ></Label>
- <Entry x:Name="entrysearch" Placeholder="Type Your text" TextChanged="OnTextChangesEvent" />
- <ListView x:Name="lstwebsearch" BackgroundColor="Azure">
- <ListView.ItemTemplate>
- <DataTemplate>
- <ViewCell>
- <StackLayout Orientation="Vertical">
- <Label Text="{Binding Snippet}">
- </Label>
- <Label Text="{Binding DisplayUrl}">
- </Label>
- <Label Text="{Binding Name}" TextColor="Gray"></Label>
- <Label Text="{Binding Url}" TextColor="Gray"></Label>
- </StackLayout>
- </ViewCell>
- </DataTemplate>
- </ListView.ItemTemplate>
- </ListView>
- </StackLayout>
- </ContentPage.Content>
- </ContentPage>


Gajendra JangidPosted Mar 10, 2018, 6:12 AM
Great article........................
Sagar Pandurang KapPosted Mar 9, 2018, 2:34 AM
Wow thats amazing.....Keep sharing.Interesting stuff..