[Vuejs]-Rails + Vue.js axios POST getting 406 Unknown Error

0👍

The code above is using Rails resources (routes.rb) without defining a default format and an Axios POST request that doesn’t specify a format.

When you submit the POST request check the rails server log and see how the controller is processing the request. I’d anticipate the above will generate the line: "Processing by CampaignsController#create as HTML".

Try either defining a default format in the routes file (https://guides.rubyonrails.org/routing.html#defining-defaults):

defaults format: :json do
  resources :campaigns
end

or specifying a format for the POST request.

axios.post('/campaigns.json', ...)...

Leave a comment