Skip to content

Commit 08bcec9

Browse files
authored
Merge pull request #114417 from dksimpson/DKS-US1712683-bing-entity-search
Refresh Bing Entity Search REST API quickstarts
2 parents fc99d33 + 15e6ac0 commit 08bcec9

File tree

7 files changed

+118
-112
lines changed

7 files changed

+118
-112
lines changed

articles/cognitive-services/Bing-Entities-Search/quickstarts/csharp.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Send a search request to the Bing Entity Search REST API using C#
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple C# application sends a news search query to the API, and displays the response. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingEntitySearchv7.cs).
1919

20-
While this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
2121

2222

2323
## Prerequisites
@@ -26,18 +26,18 @@ While this application is written in C#, the API is a RESTful Web service compat
2626

2727
- The [Json.NET](https://www.newtonsoft.com/json) framework, available as a NuGet package. To install the NuGet package in Visual Studio:
2828

29-
1. Right click your project in **Solution Explorer**.
29+
1. Right-click your project in **Solution Explorer**.
3030
2. Select **Manage NuGet Packages**.
31-
3. Search for *Newtonsoft.Json* and install the package.
31+
3. Search for and select *Newtonsoft.Json*, and then install the package.
3232

33-
- If you're using Linux/MacOS, this application can be run by using [Mono](https://www.mono-project.com/).
33+
- If you're using Linux/MacOS, this application can be run by using [Mono](https://www.mono-project.com/).
3434

3535

3636
[!INCLUDE [cognitive-services-bing-news-search-signup-requirements](../../../../includes/cognitive-services-bing-entity-search-signup-requirements.md)]
3737

3838
## Create and initialize a project
3939

40-
1. create a new C# console solution in Visual Studio. Then add the following namespaces into the main code file.
40+
1. Create a new C# console solution in Visual Studio. Then, add the following namespaces into the main code file:
4141

4242
```csharp
4343
using Newtonsoft.Json;
@@ -46,7 +46,7 @@ While this application is written in C#, the API is a RESTful Web service compat
4646
using System.Text;
4747
```
4848

49-
2. Create a new class, and add variables for the API endpoint, your subscription key, and query you want to search. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
49+
2. Create a new class, and add variables for the API endpoint, your subscription key, and the query you want to search. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
5050

5151
```csharp
5252
namespace EntitySearchSample
@@ -69,11 +69,13 @@ While this application is written in C#, the API is a RESTful Web service compat
6969

7070
## Send a request and get the API response
7171

72-
1. Within the class, create a function called `Search()`. Create a new `HttpClient` object, and add your subscription key to the `Ocp-Apim-Subscription-Key` header.
72+
1. Within the class, create a function called `Search()`. Within this function, create a new `HttpClient` object, and add your subscription key to the `Ocp-Apim-Subscription-Key` header.
7373

74-
1. Construct the URI for your request by combining the host and path. Then add your market, and URL-encode your query.
75-
2. Await `client.GetAsync()` to get a HTTP response, and then store the json response by awaiting `ReadAsStringAsync()`.
76-
3. Format the JSON string with `JsonConvert.DeserializeObject()` and print it to the console.
74+
2. Construct the URI for your request by combining the host and path. Then, add your market and URL-encode your query.
75+
76+
3. Await `client.GetAsync()` to get an HTTP response, and then store the JSON response by awaiting `ReadAsStringAsync()`.
77+
78+
4. Format the JSON string with `JsonConvert.DeserializeObject()` and print it to the console.
7779

7880
```csharp
7981
async static void Search()
@@ -92,7 +94,7 @@ While this application is written in C#, the API is a RESTful Web service compat
9294
}
9395
```
9496

95-
2. In the main method of your application, call the `Search()` function.
97+
5. In the `Main()` method of your application, call the `Search()` function.
9698

9799
```csharp
98100
static void Main(string[] args)
@@ -174,4 +176,4 @@ A successful response is returned in JSON, as shown in the following example:
174176
> [Build a single-page web app](../tutorial-bing-entities-search-single-page-app.md)
175177
176178
* [What is the Bing Entity Search API?](../overview.md )
177-
* [Bing Entity Search API Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference)
179+
* [Bing Entity Search API reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference).

articles/cognitive-services/Bing-Entities-Search/quickstarts/java.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515
# Quickstart: Send a search request to the Bing Entity Search REST API using Java
1616

1717
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple Java application sends a news search query to the API, and displays the response.
1818

19-
While this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
19+
Although this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
2020

2121
## Prerequisites
2222

23-
* The [Java Development Kit(JDK)](https://www.oracle.com/technetwork/java/javase/downloads/)
24-
* The [Gson library](https://github.com/google/gson)
23+
* The [Java Development Kit (JDK)](https://www.oracle.com/technetwork/java/javase/downloads/).
24+
* The [Gson library](https://github.com/google/gson).
2525

2626

2727
[!INCLUDE [cognitive-services-bing-news-search-signup-requirements](../../../../includes/cognitive-services-bing-entity-search-signup-requirements.md)]
2828

2929
## Create and initialize a project
3030

31-
1. Create a new Java project in your favorite IDE or editor, and import the following libraries.
31+
1. Create a new Java project in your favorite IDE or editor, and import the following libraries:
3232

3333
```java
3434
import java.io.*;
@@ -45,7 +45,7 @@ While this application is written in Java, the API is a RESTful Web service comp
4545
import com.google.gson.JsonParser;
4646
```
4747

48-
2. In a new class, create variables for the API endpoint, your subscription key, and a search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
48+
2. In a new class, create variables for the API endpoint, your subscription key, and a search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
4949

5050
```java
5151
public class EntitySearch {
@@ -63,7 +63,7 @@ While this application is written in Java, the API is a RESTful Web service comp
6363

6464
## Construct a search request string
6565

66-
1. Create a function called `search()` that returns a JSON `String`. url-encode your search query, and add it to a parameters string with `&q=`. Add your market to the string with `?mkt=`.
66+
1. Create a function called `search()` that returns a JSON `String`. url-encode your search query, and add it to a parameters string with `&q=`. Add your market to the parameter string with `?mkt=`.
6767

6868
2. Create a URL object with your host, path, and parameters strings.
6969

@@ -99,7 +99,7 @@ While this application is written in Java, the API is a RESTful Web service comp
9999
//...
100100
```
101101

102-
3. Create a `String` object to store the response from the `BufferedReader`. Iterate through it, and append each line to the string. Then close the reader, and return the response.
102+
3. Create a `String` object to store the response from the `BufferedReader`. Iterate through it, and append each line to the string. Then, close the reader and return the response.
103103

104104
```java
105105
String line;
@@ -114,9 +114,9 @@ While this application is written in Java, the API is a RESTful Web service comp
114114

115115
## Format the JSON response
116116

117-
1. Create a new function called `prettify` to format the JSON response. Create a new `JsonParser`, and call `parse()` on the json text, and store it as a JSON object.
117+
1. Create a new function called `prettify` to format the JSON response. Create a new `JsonParser`, call `parse()` on the JSON text, and then store it as a JSON object.
118118

119-
2. Use the Gson library to create a new `GsonBuilder()`, and use `setPrettyPrinting().create()` to format the json. Then return it.
119+
2. Use the Gson library to create a new `GsonBuilder()`, use `setPrettyPrinting().create()` to format the JSON, and then return it.
120120

121121
```java
122122
//...
@@ -131,7 +131,7 @@ While this application is written in Java, the API is a RESTful Web service comp
131131

132132
## Call the search function
133133

134-
1. From the main method of your project, call `search()`, and use `prettify()` to format the text.
134+
- From the main method of your project, call `search()`, and use `prettify()` to format the text.
135135

136136
```java
137137
public static void main(String[] args) {
@@ -215,5 +215,5 @@ A successful response is returned in JSON, as shown in the following example:
215215
> [!div class="nextstepaction"]
216216
> [Build a single-page web app](../tutorial-bing-entities-search-single-page-app.md)
217217

218-
* [What is the Bing Entity Search API?](../overview.md )
219-
* [Bing Entity Search API Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference)
218+
* [What is the Bing Entity Search API?](../overview.md)
219+
* [Bing Entity Search API reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference).

articles/cognitive-services/Bing-Entities-Search/quickstarts/nodejs.md

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Send a search request to the Bing Entity Search REST API using Node.js
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple JavaScript application sends a news search query to the API, and displays the response. The source code for this sample is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/nodejs/Search/BingEntitySearchv7.js).
1919

20-
While this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
2121

2222
## Prerequisites
2323

2424
* The latest version of [Node.js](https://nodejs.org/en/download/).
2525

26-
* The [JavaScript Request Library](https://github.com/request/request)
26+
* The [JavaScript Request Library](https://github.com/request/request).
2727

2828
[!INCLUDE [cognitive-services-bing-news-search-signup-requirements](../../../../includes/cognitive-services-bing-entity-search-signup-requirements.md)]
2929

3030
## Create and initialize the application
3131

32-
1. Create a new JavaScript file in your favorite IDE or editor, and set the strictness and https requirements.
32+
1. Create a new JavaScript file in your favorite IDE or editor, and set the strictness and HTTPS requirements.
3333

3434
```javaScript
3535
'use strict';
3636
let https = require ('https');
3737
```
3838

39-
2. Create variables for the API endpoint, your subscription key, and search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
39+
2. Create variables for the API endpoint, your subscription key, and search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
4040

4141
```javascript
4242
let subscriptionKey = 'ENTER YOUR KEY HERE';
@@ -54,52 +54,53 @@ While this application is written in JavaScript, the API is a RESTful Web servic
5454

5555
## Handle and parse the response
5656

57-
1. Define a function named `response_handler` that takes an HTTP call, `response`, as a parameter. Within this function, perform the following steps:
57+
1. Define a function named `response_handler()` that takes an HTTP call, `response`, as a parameter.
5858

59-
1. Define a variable to contain the body of the JSON response.
60-
```javascript
61-
let response_handler = function (response) {
62-
let body = '';
63-
};
64-
```
59+
2. Within this function, define a variable to contain the body of the JSON response.
60+
```javascript
61+
let response_handler = function (response) {
62+
let body = '';
63+
};
64+
```
6565

66-
2. Store the body of the response when the **data** flag is called
67-
```javascript
68-
response.on('data', function (d) {
69-
body += d;
70-
});
71-
```
66+
3. Store the body of the response when the `data` flag is called.
67+
```javascript
68+
response.on('data', function (d) {
69+
body += d;
70+
});
71+
```
7272

73-
3. When an **end** flag is signaled, parse the JSON, and print it.
73+
4. When an `end` flag is signaled, parse the JSON, and print it.
7474

75-
```javascript
76-
response.on ('end', function () {
77-
let json = JSON.stringify(JSON.parse(body), null, ' ');
78-
console.log (json);
79-
});
75+
```javascript
76+
response.on ('end', function () {
77+
let json = JSON.stringify(JSON.parse(body), null, ' ');
78+
console.log (json);
79+
});
8080
```
8181

8282
## Send a request
8383

84-
1. Create a function called `Search` to send a search request. In it, perform the following steps.
84+
1. Create a function called `Search()` to send a search request. In it, perform the following steps:
85+
86+
2. Within this function, create a JSON object containing your request parameters. Use `Get` for the method, and add your host and path information. Add your subscription key to the `Ocp-Apim-Subscription-Key` header.
8587

86-
1. Create a JSON object containing your request parameters: use `Get` for the method, and add your host and path information. Add your subscription key to the `Ocp-Apim-Subscription-Key` header.
87-
2. Use `https.request()` to send the request with the response handler created earlier, and your search parameters.
88+
3. Use `https.request()` to send the request with the response handler created previously, and your search parameters.
8889

89-
```javascript
90-
let Search = function () {
91-
let request_params = {
92-
method : 'GET',
93-
hostname : host,
94-
path : path + query,
95-
headers : {
96-
'Ocp-Apim-Subscription-Key' : subscriptionKey,
97-
}
98-
};
90+
```javascript
91+
let Search = function () {
92+
let request_params = {
93+
method : 'GET',
94+
hostname : host,
95+
path : path + query,
96+
headers : {
97+
'Ocp-Apim-Subscription-Key' : subscriptionKey,
98+
}
99+
};
99100

100-
let req = https.request (request_params, response_handler);
101-
req.end ();
102-
}
101+
let req = https.request (request_params, response_handler);
102+
req.end ();
103+
}
103104
```
104105

105106
2. Call the `Search()` function.
@@ -175,4 +176,4 @@ A successful response is returned in JSON, as shown in the following example:
175176
> [Build a single-page web app](../tutorial-bing-entities-search-single-page-app.md)
176177
177178
* [What is the Bing Entity Search API?](../overview.md )
178-
* [Bing Entity Search API Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference)
179+
* [Bing Entity Search API reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference).

articles/cognitive-services/Bing-Entities-Search/quickstarts/php.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Send a search request to the Bing Entity Search REST API using PHP
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple PHP application sends a news search query to the API, and displays the response.
1919

20-
While this application is written in PHP, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in PHP, the API is a RESTful Web service compatible with most programming languages.
2121

2222
## Prerequisites
2323

@@ -27,12 +27,12 @@ While this application is written in PHP, the API is a RESTful Web service compa
2727

2828
## Search entities
2929

30-
To run this application, follow these steps.
30+
To run this application, follow these steps:
3131

3232
1. Create a new PHP project in your favorite IDE.
3333
2. Add the code provided below.
3434
3. Replace the `key` value with an access key valid for your subscription.
35-
4. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
35+
4. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
3636
5. Run the program.
3737

3838
```php
@@ -79,7 +79,7 @@ echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
7979
?>
8080
```
8181

82-
**Response**
82+
## Example JSON response
8383

8484
A successful response is returned in JSON, as shown in the following example:
8585

@@ -150,4 +150,4 @@ A successful response is returned in JSON, as shown in the following example:
150150
> [Build a single-page web app](../tutorial-bing-entities-search-single-page-app.md)
151151
152152
* [What is the Bing Entity Search API?](../overview.md )
153-
* [Bing Entity Search API Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference)
153+
* [Bing Entity Search API reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference).

0 commit comments

Comments
 (0)