LoginSignup
0
0

More than 1 year has passed since last update.

ActionDispatch::Http::Parameters::ParseError: 859の対処方法メモ

Posted at

環境

macOS Monterey 12.3.1
ruby 3.1.2
rails 6.1.6

エラー内容

Talend API TesterでRails APIのテストを実施していたところ、以下のエラーが発生した。

Talend API Tester
{
  "status": 400,
  "error": "Bad Request",
  "exception": "#<ActionDispatch::Http::Parameters::ParseError: 859: unexpected token at '{\n  
  \"name\": \"team1\",\n}\n'>",
  ...
}

発生時の状況

POST "http://localhost:3000/api/v1/teams" で以下の情報を送信していた。

{
  "name": "team1",
}

コントローラは以下の様に設定していた。

teams_controller.rb
class Api::V1::TeamsController < ApplicationController

  def create
    team = Team.new(team_params)
    if team.save
      render json: { team: }, status: :created
    else
      render json: {}, status: :internal_server_error
    end
  end
end

対処方法

こちらの記事を参考に、JSONLint に送信したjsonをコピペしてチェックしました。
末尾に不要なコンマが入っていたため、エラーが発生していました。
修正後、無事リクエストが通るようになりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0