Created
May 15, 2020 15:07
-
-
Save rob-derosa/453c9fd6e7a3571a1e138dfaff559a48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -i -X POST "https://robsformrecognizerresource.cognitiveservices.azure.com/formrecognizer/v2.0-preview/prebuilt/receipt/analyze" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: 502a443d06...d409a5081b587c8d68b" --data-ascii "{ \"url\": \"https://formrecgonizerstorage.blob.core.windows.net/forms/receipt_1_rotated.png\"}" | |
async static Task RunReceipt() | |
{ | |
var receiptUrl = "https://formrecgonizerstorage.blob.core.windows.net/forms/receipt_1_rotated.png"; | |
var uri = "https://robsformrecognizerresource.cognitiveservices.azure.com/formrecognizer/v2.0-preview/prebuilt/receipt/analyze"; | |
object body = new { url = receiptUrl }; | |
var requestBody = JsonConvert.SerializeObject(body); | |
//body: {"url":"https://formrecgonizerstorage.blob.core.windows.net/forms/receipt_1_rotated.png"} | |
Console.WriteLine(requestBody); | |
using (var client = new HttpClient()) | |
using (var request = new HttpRequestMessage()) | |
{ | |
request.Method = HttpMethod.Post; | |
request.RequestUri = new Uri(uri); | |
request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json"); | |
request.Headers.Add("Ocp-Apim-Subscription-Key", "502a......4d409a5081b587c8d68b"); | |
var response = await client.SendAsync(request); | |
var responseBody = await response.Content.ReadAsStringAsync(); | |
dynamic data = JsonConvert.DeserializeObject(responseBody); | |
Console.WriteLine(responseBody); | |
} | |
} | |
//output: {"error":{"code":"InvalidImageURL","innerError":{"requestId":"890a4ee3-a2b9-4c12-9b1d-baa5042a076f"},"message":"Image URL is badly formatted."}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment