Skip to content

Commit 20cda2c

Browse files
author
dksimpson
committed
Edits
1 parent bea9f3d commit 20cda2c

File tree

6 files changed

+50
-50
lines changed

6 files changed

+50
-50
lines changed

articles/cognitive-services/bing-visual-search/quickstarts/csharp.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-visual-search
1111
ms.topic: quickstart
12-
ms.date: 05/21/2020
12+
ms.date: 05/22/2020
1313
ms.author: scottwhi
1414
---
1515

@@ -37,15 +37,15 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
3737
using System.Collections.Generic;
3838
```
3939

40-
2. Add variables for your subscription key, endpoint, and path to the image you want to upload. For the `uriBase` value, 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:
40+
2. Add variables for your subscription key, endpoint, and path to the image you want to upload. For the `uriBase` value, 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.
4141

4242
```csharp
4343
const string accessKey = "<my_subscription_key>";
4444
const string uriBase = "https://api.cognitive.microsoft.com/bing/v7.0/images/visualsearch";
4545
static string imagePath = @"<path_to_image>";
4646
```
4747

48-
3. Create a method named `GetImageFileName()` to get the path for your image:
48+
3. Create a method named `GetImageFileName()` to get the path for your image.
4949

5050
```csharp
5151
static string GetImageFileName(string path)
@@ -54,7 +54,7 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
5454
}
5555
```
5656

57-
4. Create a method to get the binary data of the image:
57+
4. Create a method to get the binary data of the image.
5858

5959
```csharp
6060
static byte[] GetImageBinary(string path)
@@ -65,7 +65,7 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
6565

6666
## Build the form data
6767

68-
1. To upload a local image, first build the form data to send to the API. The form data includes the `Content-Disposition` header, the `name` parameter set to "image", and the `filename` parameter set to any string. The contents of the form contain the binary data of the image. The maximum image size you can upload is 1 MB.
68+
1. To upload a local image, first build the form data to send to the API. The form data includes the `Content-Disposition` header, the `name` parameter set to "image", and the `filename` parameter set to the file name of the image. The contents of the form contain the binary data of the image. The maximum image size you can upload is 1 MB.
6969

7070
```
7171
--boundary_1234-abcd
@@ -76,7 +76,7 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
7676
--boundary_1234-abcd--
7777
```
7878

79-
2. Add boundary strings to format the POST form data. Boundary strings determine the start, end, and newline characters for the data:
79+
2. Add boundary strings to format the POST form data. Boundary strings determine the start, end, and newline characters for the data.
8080

8181
```csharp
8282
// Boundary strings for form data in body of POST.
@@ -93,7 +93,7 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
9393
const string POST_BODY_DISPOSITION_HEADER = "Content-Disposition: form-data; name=\"image\"; filename=\"{0}\"" + CRLF +CRLF;
9494
```
9595

96-
4. Create a function named `BuildFormDataStart()` to create the start of the form data using the boundary strings and image path:
96+
4. Create a function named `BuildFormDataStart()` to create the start of the form data by using the boundary strings and image path.
9797

9898
```csharp
9999
static string BuildFormDataStart(string boundary, string filename)
@@ -107,7 +107,7 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
107107
}
108108
```
109109

110-
5. Create a function named `BuildFormDataEnd()` to create the end of the form data using the boundary strings:
110+
5. Create a function named `BuildFormDataEnd()` to create the end of the form data by using the boundary strings.
111111

112112
```csharp
113113
static string BuildFormDataEnd(string boundary)
@@ -154,14 +154,14 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
154154

155155
## Create the Main method
156156

157-
1. In the `Main()` method of your application, get the filename and binary data of your image:
157+
1. In the `Main()` method of your application, get the filename and binary data of your image.
158158

159159
```csharp
160160
var filename = GetImageFileName(imagePath);
161161
var imageBinary = GetImageBinary(imagePath);
162162
```
163163

164-
2. Set up the POST body by formatting the boundary for it. Then, call `startFormData()` and `endFormData` to create the form data:
164+
2. Set up the POST body by formatting its boundary. Then, call `BuildFormDataStart()` and `BuildFormDataEnd()` to create the form data.
165165

166166
```csharp
167167
// Set up POST body.
@@ -170,13 +170,13 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
170170
var endFormData = BuildFormDataEnd(boundary);
171171
```
172172

173-
3. Create the `ContentType` value by formatting `CONTENT_TYPE_HEADER_PARAMS` and the form data boundary:
173+
3. Create the `ContentType` value by formatting `CONTENT_TYPE_HEADER_PARAMS` and the form data boundary.
174174

175175
```csharp
176176
var contentTypeHdrValue = string.Format(CONTENT_TYPE_HEADER_PARAMS, boundary);
177177
```
178178

179-
4. Get the API response by calling `BingImageSearch()`, and then print the response:
179+
4. Get the API response by calling `BingImageSearch()`, and then print the response.
180180

181181
```csharp
182182
var json = BingImageSearch(startFormData, endFormData, imageBinary, contentTypeHdrValue);
@@ -187,7 +187,7 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
187187

188188
## Using HttpClient
189189

190-
If you use `HttpClient`, you can use the `MultipartFormDataContent` class to build the form data. Use the following sections of code to replace the corresponding methods in the previous example.
190+
If you use `HttpClient`, you can use the `MultipartFormDataContent` class to build the form data. Use the following sections of code to replace the corresponding methods in the previous example:
191191

192192
1. Replace the `Main()` method with the following code:
193193

articles/cognitive-services/bing-visual-search/quickstarts/go.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-visual-search
1111
ms.topic: quickstart
12-
ms.date: 05/21/2020
12+
ms.date: 05/22/2020
1313
ms.author: aahi
1414
---
1515

@@ -232,7 +232,7 @@ resp, err := client.Do(req)
232232

233233
## Handle the response
234234

235-
The `Unmarshall` function extracts information from the JSON text returned by the Visual Search API. The `go-spew` pretty printer displays the results:
235+
The `Unmarshall` function extracts information from the JSON text returned by the Visual Search API. The `go-spew` pretty printer displays the results.
236236

237237
```go
238238
// Create a new answer.
@@ -255,7 +255,7 @@ The `Unmarshall` function extracts information from the JSON text returned by th
255255
256256
## Results
257257

258-
The results identify images similar to the image contained in the POST body. The useful fields are `WebSearchUrl` and `Name`:
258+
The results identify images similar to the image contained in the POST body. The useful fields are `WebSearchUrl` and `Name`.
259259

260260
```go
261261
Value: ([]struct { WebSearchUrl string "json:\"webSearchUrl\""; Name string "json:\"name\"" }) (len=66 cap=94) {

articles/cognitive-services/bing-visual-search/quickstarts/java.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-visual-search
1111
ms.topic: quickstart
12-
ms.date: 05/21/2020
12+
ms.date: 05/22/2020
1313
ms.author: scottwhi
1414
---
1515

@@ -48,7 +48,7 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
4848
import org.apache.http.impl.client.HttpClientBuilder;
4949
```
5050

51-
2. Create variables for your API endpoint, subscription key, and the path to your image. For the `endpoint` value, 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:
51+
2. Create variables for your API endpoint, subscription key, and the path to your image. For the `endpoint` value, 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.
5252

5353
```java
5454
static String endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/images/visualsearch";
@@ -57,7 +57,7 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
5757
```
5858

5959

60-
3. When you upload a local image, the form data must include the `Content-Disposition` header. Set its `name` parameter to "image", and set the `filename` parameter to any string. The contents of the form include the binary data of the image. The maximum image size you can upload is 1 MB.
60+
3. When you upload a local image, the form data must include the `Content-Disposition` header. Set its `name` parameter to "image", and set the `filename` parameter to the file name of the image. The contents of the form include the binary data of the image. The maximum image size you can upload is 1 MB.
6161

6262
```
6363
--boundary_1234-abcd
@@ -70,7 +70,7 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
7070
7171
## Create the JSON parser
7272
73-
Create a method to make the JSON response from the API more readable by using `JsonParser`:
73+
Create a method to make the JSON response from the API more readable by using `JsonParser`.
7474
7575
```java
7676
public static String prettify(String json_text) {
@@ -83,13 +83,13 @@ public static String prettify(String json_text) {
8383
8484
## Construct the search request and query
8585
86-
1. In the main method of your application, create an HTTP client using `HttpClientBuilder.create().build();`:
86+
1. In the main method of your application, create an HTTP client using `HttpClientBuilder.create().build();`.
8787
8888
```java
8989
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
9090
```
9191
92-
2. Create an `HttpEntity` object to upload your image to the API:
92+
2. Create an `HttpEntity` object to upload your image to the API.
9393
9494
```java
9595
HttpEntity entity = MultipartEntityBuilder
@@ -98,7 +98,7 @@ public static String prettify(String json_text) {
9898
.build();
9999
```
100100
101-
3. Create an `httpPost` object with your endpoint, and set the header to use your subscription key:
101+
3. Create an `httpPost` object with your endpoint, and set the header to use your subscription key.
102102
103103
```java
104104
HttpPost httpPost = new HttpPost(endpoint);
@@ -108,14 +108,14 @@ public static String prettify(String json_text) {
108108
109109
## Receive and process the JSON response
110110
111-
1. Use the `HttpClient.execute()` method to send a request to the API, and store the response in an `InputStream` object:
111+
1. Use the `HttpClient.execute()` method to send a request to the API, and store the response in an `InputStream` object.
112112
113113
```java
114114
HttpResponse response = httpClient.execute(httpPost);
115115
InputStream stream = response.getEntity().getContent();
116116
```
117117
118-
2. Store the JSON string, and print the response:
118+
2. Store the JSON string, and print the response.
119119
120120
```java
121121
String json = new Scanner(stream).useDelimiter("\\A").next();

articles/cognitive-services/bing-visual-search/quickstarts/nodejs.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-visual-search
1111
ms.topic: quickstart
12-
ms.date: 05/21/2020
12+
ms.date: 05/22/2020
1313
ms.author: scottwhi
1414
---
1515

@@ -35,15 +35,15 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
3535
var fs = require('fs');
3636
```
3737

38-
2. Create variables for your API endpoint, subscription key, and the path to your image. For the `baseUri` value, 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:
38+
2. Create variables for your API endpoint, subscription key, and the path to your image. For the `baseUri` value, 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.
3939

4040
```javascript
4141
var baseUri = 'https://api.cognitive.microsoft.com/bing/v7.0/images/visualsearch';
4242
var subscriptionKey = 'your-api-key';
4343
var imagePath = "path-to-your-image";
4444
```
4545

46-
3. Create a function named `requestCallback()` to print the response from the API:
46+
3. Create a function named `requestCallback()` to print the response from the API.
4747

4848
```javascript
4949
function requestCallback(err, res, body) {
@@ -53,7 +53,7 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
5353

5454
## Construct and send the search request
5555

56-
1. When you upload a local image, the form data must include the `Content-Disposition` header. Set its `name` parameter to "image", and set the `filename` parameter to any string. The contents of the form include the binary data of the image. The maximum image size you can upload is 1 MB.
56+
1. When you upload a local image, the form data must include the `Content-Disposition` header. Set its `name` parameter to "image", and set the `filename` parameter to the file name of your image. The contents of the form include the binary data of the image. The maximum image size you can upload is 1 MB.
5757

5858
```
5959
--boundary_1234-abcd
@@ -64,14 +64,14 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
6464
--boundary_1234-abcd--
6565
```
6666
67-
2. Create a new `FormData` object with `FormData()`, and append your image path to it by using `fs.createReadStream()`:
67+
2. Create a new `FormData` object with `FormData()`, and append your image path to it by using `fs.createReadStream()`.
6868
6969
```javascript
7070
var form = new FormData();
7171
form.append("image", fs.createReadStream(imagePath));
7272
```
7373
74-
3. Use the request library to upload the image, and call `requestCallback()` to print the response. Add your subscription key to the request header:
74+
3. Use the request library to upload the image, and call `requestCallback()` to print the response. Add your subscription key to the request header.
7575
7676
```javascript
7777
form.getLength(function(err, length){

articles/cognitive-services/bing-visual-search/quickstarts/python.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-visual-search
1111
ms.topic: quickstart
12-
ms.date: 05/21/2020
12+
ms.date: 05/22/2020
1313
ms.author: scottwhi
1414
---
1515

@@ -40,7 +40,7 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
4040
imagePath = 'your-image-path'
4141
```
4242

43-
3. When you upload a local image, the form data must include the `Content-Disposition` header. Set its `name` parameter to "image", and set the `filename` parameter to any string. The contents of the form include the binary data of the image. The maximum image size you can upload is 1 MB.
43+
3. When you upload a local image, the form data must include the `Content-Disposition` header. Set its `name` parameter to "image", and set the `filename` parameter to the file name of your image. The contents of the form include the binary data of the image. The maximum image size you can upload is 1 MB.
4444

4545
```
4646
--boundary_1234-abcd
@@ -51,21 +51,21 @@ Use this quickstart to make your first call to the Bing Visual Search API. This
5151
--boundary_1234-abcd--
5252
```
5353

54-
4. Create a dictionary object to hold your request's header information. Bind your subscription key to the string `Ocp-Apim-Subscription-Key`:
54+
4. Create a dictionary object to hold your request's header information. Bind your subscription key to the string `Ocp-Apim-Subscription-Key`.
5555

5656
```python
5757
HEADERS = {'Ocp-Apim-Subscription-Key': SUBSCRIPTION_KEY}
5858
```
5959

60-
5. Create another dictionary to contain your image, which is opened and uploaded when you send the request:
60+
5. Create another dictionary to contain your image, which is opened and uploaded when you send the request.
6161

6262
```python
6363
file = {'image' : ('myfile', open(imagePath, 'rb'))}
6464
```
6565

6666
## Parse the JSON response
6767

68-
Create a method called `print_json()` to accept the API response, and print the JSON:
68+
Create a method called `print_json()` to accept the API response, and print the JSON.
6969

7070
```python
7171
def print_json(obj):
@@ -75,7 +75,7 @@ def print_json(obj):
7575

7676
## Send the request
7777

78-
Use `requests.post()` to send a request to the Bing Visual Search API. Include the string for your endpoint, header, and file information. Print `response.json()` with `print_json()`:
78+
Use `requests.post()` to send a request to the Bing Visual Search API. Include the string for your endpoint, header, and file information. Print `response.json()` with `print_json()`.
7979

8080
```python
8181
try:

0 commit comments

Comments
 (0)