• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Sending email through springboot and angular

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a contact form for a project that i am doing for school, but in our project we are using jhipster. jhipster uses springboot and angular and even though i have experience with spring boot, angular is giving me problems. My problem in my code is that it is not sending the email that i have made in my java implementation. When i press submit it defaults to my fallback error. Since I am new to angular I am having trouble understanding where the problem is generating from. Please help me, i have been trying for two weeks now with no success.







 
Sheriff
Posts: 21783
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@RequestMapping requires you to set the allowed HTTP methods when used on a method level. You should use either @RequestMapping(path = "/api/contact", method = RequestMethod.POST), or shorter @PostMapping("/api/contact"). You might then run into 415 errors; that can be solved by setting the consumes property correctly (to HttpMethod.APPLICAITON_JSON_VALUE).
 
Henna Ghayas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for replying, could you explain what the complains property is? I have never heard of it
 
Henna Ghayas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean consumes
 
Rob Spoor
Sheriff
Posts: 21783
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The consumes property is used to define which request Content-Type headers are accepted. Likewise, the produces property is used to define what Content-Type the response has.

I actually don't know what happens if you don't define any consumes for a POST or PUT request. It may accept everything, or it may accept nothing. If you want to accept any Content-Type header you can use MediaType.ALL_VALUE.
 
Henna Ghayas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i know this is a long time after but I wanted to ask, I was actually able to get the email sent but now the contents of the message are all null, do you have any idea of a reason that could happen?
 
Rob Spoor
Sheriff
Posts: 21783
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open your browser's development tools and check what the POST request actually contains.
 
We can walk to school together. And we can both read this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!