I used the following code to call the web service, but it didn't work. I have used postman to test successfully. Here is the demo.
-
$body = @{ "access_token"="24.b305c9822131e65eda05e29c157dd719.2592000.1559103982.282335-16139329", "image"="base64", "language_type"="CHN_ENG", "probability"="true", "detect_direction"="true" } $header = @{ "Content-Type"="application/x-www-form-urlencoded" } Invoke-RestMethod -Uri "aip.baidubce.com/rest/2.0/ocr/v1/general_basic" -Method 'Post' -Body $body -Headers $header– tianyiMay 4, 2019 at 7:11
-
My code can't be used, need to be modified, thanks in advance– tianyiMay 4, 2019 at 7:12
-
Don't post code snippets in comments; Please edit the question instead and add a minimal reproducible example and format it properly using the {} (code sample icon above the editing area).– JosefZMay 4, 2019 at 8:20
Add a comment
|
1 Answer
Try this :
$body = @{
"access_token" = "24.b305c9822131e65eda05e29c157dd719.2592000.1559103982.282335-16139329";
"image" = "base64";
"language_type" = "CHN_ENG";
"probability" = "true";
"detect_direction" = "true";
}
$header = @{
"Content-Type" = "application/x-www-form-urlencoded"
}
$response = Invoke-RestMethod -Uri "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic" -Method POST -Body $body -Headers $header | ConvertTo-Json
$response | Out-File C:\filename.txt
-
Thanks for your help, now have the following tips The "=" operator is missing after the key in the hash text. At line: 9 char: 8– tianyiMay 4, 2019 at 10:34
-
tip: Invoke-WebRequest -Uri "aip.baidubce.com/rest/2.0/ocr/v1/general_basic" -Method POST -Body $body -Headers $header -UseBasicParsing The "Invoke-WebRequest" item cannot be recognized as a cmdlet, function, script file, or the name of a runnable program. Please check the spelling of the name. If you include the path, make sure the path is correct and try again. Location Line: 12 characters: 18– tianyiMay 4, 2019 at 10:39
-
aip.baidubce.com/rest/2.0/ocr/v1/general_basic Changed to aip.baidubce.com/rest/2.0/ocr/v1/general_basic Still prompted error– tianyiMay 4, 2019 at 10:44
-
-