• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring JPA POST Request Not Working

 
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a simple Spring JPA application and my post request, though "working", is only adding blank lines to the database.

Wondering what I'm doing wrong.

---

Here's my POSTMAN POST request:
{
"pro_pk" : "null",
"mailer_name" : "xyz tansport"
}


I have the content type set as application/json

(MySQL is auto-incrmenting the primary key so I'm passing null for pro_pk)

-----

My Controller Class method is:

// save an order

-----

My Service class method is:



---

When I debug the service method or the controller method, both the pro_pk and mailer_name are null so they're not getting passed in.

What do I need to do? I tried a @PathVariable in the controller class method, but threw 500 errors.

Thanks in advance,

- mike




 
Mike London
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved the problems.

1. The JSON fields needed to look like the Java variables, NOT the database fields.

2. I needed a @RequestBody inside the save method (and update, too).

Now that I've solved these issues, it seems anyone with decent Spring background would spot these issues right away, leading me to believe nobody read my this post (or perhaps also the one I updated over a day ago).

---

Moreover, it's strange that there have been no replies from JR (from my two recent Spring postings) other than pointing out my formatting was incorrect or that I'd copied the same method twice. In years past, JR was alive with activity. Perhaps this is just how the Spring forum is? Or maybe other sites like Stack are more popular now? Not sure.

But using a framework like Spring makes me nervous. Why? Well, if everything "works", the sun is shining and the sky is blue and you're amazingly more productive. Yet, when something doesn't work, it can take frustrating days to figure it out. Maybe the forum folks here are too busy figuring out their own Spring problems?

- mike
 
reply
    Bookmark Topic Watch Topic
  • New Topic