Form Recognizer API with Python for PDF throwing "BadArgument" error
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- api, documentation
調査の方向性
まず「Extract text and layout information using the Form Recognizer REST API with Python」Quickstart に従い、そのリクエストを、失敗している get_url 関数および報告されている Form Recognizer v2.1 エンドポイントと比較します。提供された PDF リクエストを使用して BadArgument 応答を再現し、修正された Quickstart がエラーなしで操作 URL を返すことを確認します。
索引モデルが issue の本文から書いたものです。
説明
The issue
The Quickstart for Form Recognizer REST API with Python is not functioning any more. It throws the following error:
POST analyze failed:
{"error":{"code":"BadArgument","message":"Bad or unrecognizable request JSON or binary file."}}
Not sure if this has to do with the update to Form Recognizer REST API v3.0, but is not functioning for PDF anymore. It worked a few weeks ago.
My code
from requests import get, post, Request, Session
endpoint = r"https://westeurope.api.cognitive.microsoft.com"
key = "<my_personal_key"
source = r"<path to pdf>"
def get_url(filename, endpoint, apim_key):
# v2.1
post_url = endpoint + "/formrecognizer/v2.1/layout/analyze"
headers = {
# Request headers
'Content-Type': 'application/pdf',
'Ocp-Apim-Subscription-Key': apim_key,
}
with open(filename, "rb") as f:
data_bytes = f.read()
try:
resp = post(post_url, data=data_bytes, headers=headers)
if resp.status_code != 202:
print("POST analyze failed:\n%s" % resp.text)
return None
print("POST analyze succeeded: %s" % resp.headers["operation-location"])
get_url = resp.headers["operation-location"]
return get_url
except Exception as e:
print("POST request failed:\n%s" % str(e))
return None
resp_url = get_url(source, endpoint, key)
This issue is for a: (mark with an x)
- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [x] regression (a behavior that used to work and stopped in a new release)
Minimal steps to reproduce
Follow the Quickstart: Extract text and layout information using the Form Recognizer REST API with Python
Any log messages given by the failure
POST analyze failed:
{"error":{"code":"BadArgument","message":"Bad or unrecognizable request JSON or binary file."}}
Expected/desired behavior
I would expect to get a url returned
OS and Version?
Working on Windows 10, using Visual Studio Code
Versions
requests == 2.28.1
Python == 3.9.13
- 主要言語
- Jupyter Notebook
- スター
- 388
- フォーク
- 556
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Azure-Samples/cognitive-services-quickstart-code のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
Azure-Samples/cognitive-services-quickstart-code#346 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
Azure-Samples/cognitive-services-quickstart-code の issue をすべて見る
似ている issue
-
area-signalr
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dotnet/aspnetcore#69842 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Custom hosts written as trailing-dot FQDNs (`host.local.`) aren't detected as local backends対応中かも @roboomp が今日担当しました。 オープンbug prio:p2 providers triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
can1357/oh-my-pi#15798 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
Phase 2 PSA Capability & Career Profile
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fastmachinelearning/hls4ml#1582 ·
メンテナーはふだん 3 日以内に返信