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-visual-search/quickstarts/csharp.md
+90-90Lines changed: 90 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,13 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-visual-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/17/2019
12
+
ms.date: 05/22/2020
13
13
ms.author: scottwhi
14
14
---
15
15
16
16
# Quickstart: Get image insights using the Bing Visual Search REST API and C#
17
17
18
-
This quickstart demonstrates how to upload an image to the Bing Visual Search API and to view the insights that it returns.
18
+
This quickstart demonstrates how to upload an image to the Bing Visual Search API and view the insights that it returns.
19
19
20
20
## Prerequisites
21
21
@@ -37,15 +37,15 @@ This quickstart demonstrates how to upload an image to the Bing Visual Search AP
37
37
usingSystem.Collections.Generic;
38
38
```
39
39
40
-
2. Addvariablesfor your subscription key, endpoint, and path to the image you want to upload. `uriBase` can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpointdisplayedintheAzureportalfor your resource:
40
+
2. Addvariablesfor 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) endpointdisplayedintheAzureportalfor your resource.
@@ -187,81 +187,81 @@ To upload a local image, you first build the form data to send to the API. The f
187
187
188
188
## Using HttpClient
189
189
190
-
Ifyouuse `HttpClient`, youcanusethe `MultipartFormDataContent` classto build the form data. Just use the following sections of code to replace the corresponding methods in the previous example.
Ifyouuse `HttpClient`, youcanusethe `MultipartFormDataContent` classto build the form data. Use the following sections of code to replace the corresponding methods in the previous example:
Copy file name to clipboardExpand all lines: articles/cognitive-services/bing-visual-search/quickstarts/go.md
+19-9Lines changed: 19 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,24 +9,24 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-visual-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/17/2019
12
+
ms.date: 05/22/2020
13
13
ms.author: aahi
14
14
---
15
15
16
16
# Quickstart: Get image insights using the Bing Visual Search REST API and Go
17
17
18
-
This quickstart uses the Go programming language to call the Bing Visual Search API and display results. A POST request uploads an image to the API endpoint. The results include URLs and descriptive information about images similar to the uploaded image.
18
+
Use this quickstart to make your first call to the Bing Visual Search API using the Go programming language. A POST request uploads an image to the API endpoint. The results include URLs and descriptive information about images similar to the uploaded image.
19
19
20
20
## Prerequisites
21
21
22
22
* Install the [Go binaries](https://golang.org/dl/).
23
-
*The go-spew deep pretty printeris used to display results. You can install go-spew with the `$ go get -u https://github.com/davecgh/go-spew` command.
23
+
*Install the go-spew deep pretty printer, which is used to display results. To install go-spew, use the `$ go get -u https://github.com/davecgh/go-spew` command.
Create a Go project in your IDE or editor. Then import `net/http` for requests, `ioutil` to read the response, and `encoding/json` to handle the JSON text of results. The `go-spew` library is used to parse JSON results.
29
+
Create a Go project in your IDE or editor. Then, import `net/http` for requests, `ioutil` to read the response, and `encoding/json` to handle the JSON text of results. Use the `go-spew` library to parse JSON results.
30
30
31
31
```go
32
32
package main
@@ -105,7 +105,12 @@ type BingAnswer struct {
105
105
106
106
## Main function and variables
107
107
108
-
The following code declares the main function and assigns required variables. Confirm that the endpoint is correct and replace the `token` value with a valid subscription key from your Azure account. The `batchNumber` is a GUID required for leading and trailing boundaries of the POST data. The `fileName` variable identifies the image file for the POST. `endpoint` can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource:
108
+
The following code declares the main function and assigns the required variables:
109
+
110
+
1. Confirm that the endpoint is correct and replace the `token` value with a valid subscription key from your Azure account.
111
+
2. For `batchNumber`, assign a GUID, which is required for the leading and trailing boundaries of the POST data.
112
+
3. For `fileName`, assign the image file to use for the POST.
113
+
4. For `endpoint`, 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.
109
114
110
115
```go
111
116
funcmain() {
@@ -155,7 +160,12 @@ func main() {
155
160
156
161
## Boundaries of POST body
157
162
158
-
A POST request to the Visual Search endpoint requires leading and trailing boundaries enclosing the POST data. The leading boundary includes a batch number, the content type identifier `Content-Disposition: form-data; name="image"; filename=`, plus the filename of the image to POST. The trailing boundary is simply the batch number. These functions are not included in the `main` block:
163
+
A POST request to the Visual Search endpoint requires leading and trailing boundaries to enclose the POST data. These functions aren't included in the `main()` block.
164
+
165
+
The leading boundary includes a batch number, the content type identifier `Content-Disposition: form-data; name="image"; filename=`, and the filename of the image to POST.
166
+
167
+
The trailing boundary includes the batch number only.
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.
226
236
227
237
```go
228
238
// Create a new answer.
@@ -245,7 +255,7 @@ The `Unmarshall` function extracts information from the JSON text returned by th
245
255
246
256
## Results
247
257
248
-
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`.
0 commit comments