プロジェクト

全般

プロフィール

Vote #77971

未完了

Improve exceptions handling

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
REST API_32
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
32
version_id:
0
issue_org_id:
24323
author_id:
123153
assigned_to_id:
0
comments:
0
status_id:
1
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

Hello,
I would like to improve REST api. Now you can use this request and specify requested format directly in the url like this:

    $.ajax('/myurl.json', {
      method: 'POST',
      data: {}
...

but I expect this should work aswell

    $.ajax('/myurl', {
      method: 'POST',
      data: {}
      dataType: 'json'
...

but the server responds with text (plain) 500 internal error - no builder for format

http://api.jquery.com/jQuery.ajax/
dataType (default: Intelligent Guess (xml, json, script, or html))
Type: String
The type of data that you're expecting back from the server.

before
status: 500
body: -
format: plain

patched
status: 422
body: {"errors":[{"error": "Something is wrong"}]}
format: json

I have also improved the render_error method, now you'll get a proper error message according to the format you're asking for. For instance an api request (post /something.json):
before:
status: 422
body: -

patched:
status: 422
body: {"errors":[{"error": "Something is wrong"}]}

Environment:
Redmine version 3.3.1.devel
Ruby version 2.1.5-p273 (2014-11-13) [x64-mingw32]
Rails version 4.2.7.1
Environment production
Database adapter Mysql2
SCM:
Git 2.10.1
Filesystem
Redmine plugins:
no plugin installed

Admin Redmine さんが約4年前に更新

  • カテゴリREST API_32 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0