You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Entities-Search/quickstarts/csharp.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,11 +69,13 @@ Although this application is written in C#, the API is a RESTful Web service com
69
69
70
70
## Send a request and get the API response
71
71
72
-
1. Withinthe 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. Withinthe 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.
73
73
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 an 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.
77
79
78
80
```csharp
79
81
async static void Search()
@@ -92,7 +94,7 @@ Although this application is written in C#, the API is a RESTful Web service com
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Entities-Search/quickstarts/nodejs.md
+36-35Lines changed: 36 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,52 +54,53 @@ Although this application is written in JavaScript, the API is a RESTful Web ser
54
54
55
55
## Handle and parse the response
56
56
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.
58
58
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
+
```
65
65
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
+
```
72
72
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.
74
74
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
+
});
80
80
```
81
81
82
82
## Send a request
83
83
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.
85
87
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 previously, and your search parameters.
88
+
3. Use `https.request()` to send the request with the response handler created previously, and your search parameters.
88
89
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
+
};
99
100
100
-
let req =https.request (request_params, response_handler);
101
-
req.end ();
102
-
}
101
+
let req =https.request (request_params, response_handler);
0 commit comments