• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Error 405 Method Not Allowed when sending a PUT AJAX request to Spring Boot with jQuery?

 
Ranch Hand
Posts: 148
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I sincerely hope that I'm in appropriate forum.

My question is related with JavaScript (AJAX) and Spring Boot. So here it goes:

I'm getting 405 in console, when I send PUT request.

Here is my ajax call, which is part of bigger function:



I have a Promise object to handle asynchronous nature of ajax:



Now on the server side I have following, I have simple Task model object with omitted non relevant fields:



My controller class in Spring Boot and endpoint method for updating look like this:



I keep getting in the browser console 405. And on the console on server, I have following message:



I don't have SpringSecurity dependency...

I also asked on SO, but no luck..I really want to make PUT do the actual updating of the object, don't want to use POST, but that will be my last resort.
 
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure that the URL you are hitting is correct?
 
Mike Gosling
Ranch Hand
Posts: 148
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Absolutely. Test it with Postman as well, again 405.
 
Saloon Keeper
Posts: 14710
331
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try removing the the value attribute from your @PutMapping. It could be that a single slash is interpreted as the root path and not relative to your /api/tasks path.
 
Mike Gosling
Ranch Hand
Posts: 148
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In my code I had:



It should have been


like I actually posted...
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write POST instead of PUT
 
reply
    Bookmark Topic Watch Topic
  • New Topic