2016-08-20 5 views
0

私はRESTインターフェースを構築しました。 '400 Bad Request'では、エラーに関する特定の情報を持つJSON本体を返します。URLErrorがjson本体を返さない

(Pdb) error.code 
400 

Pythonが正しくあり236文字の内容があるが、私は体を読むための方法を見つけることができませんこれらのヘッダと

(Pdb) print(error.headers) 

Cache-Control: no-cache 
Pragma: no-cache 
Content-Type: application/json; charset=utf-8 
Expires: -1 
Server: Microsoft-IIS/7.5 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 
Date: Sat, 20 Aug 2016 13:01:05 GMT 
Connection: close 
Content-Length: 236 

をURLErrorをスローします。

私はしかし、私はここで

は、私が試してみましたいくつかのものであり、何をした身体を読み取るためにPythonで方法を見つけることができませんDHCクロームプラグインに

{ 
"error_code": "00000001", 
"error_message": "The json data is not in the correct json format.\r\nThe json data is not in the correct json format.\r\n'Execution Start Time' must not be empty.\r\n'Execution End Time' must not be empty.\r\n" 
} 

を使用して、余分な情報を見ることができます戻ってきた。

(Pdb) len(error.read()) 

0 

error.read().decode('utf-8', 'ignore') 

'' 

(Pdb) error.readline() 

b'' 
+0

さらに詳しい情報が得られるようにコードを入力してください。 – nir0s

答えて

0

これは最初に呼び出されますが、再度呼び出すと機能しません。

error.read()。decode( 'utf-8')

関連する問題