• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring restful webservice issue not taking Json

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey!

So I am having a slight issue with my restful webservice taking Json. It takes the Java object as a good request but every time I use Json it gives me a 400 bad request.

Here is my test class:


You can see in the comments that I tried the object with a "createUser()" and that gave me no problems and put something in the DB. But Json just wont work.

Below is the Webservice Object:


Here is the webservice endpoint:


Here is the Jsons I have tried:

{"Users":["position": 2, "formula": "sadasd","userId": 3 ,
"firstName": "", "lastName": "", "userName": "",
"password": "", "userSocialAccounts": true, "userPrivacy": "",
"email": "", "bio": "", "profilePicUrl": ""]}

and

{"Users":{"position": 2, "formula": "sadasd","userId": 3 ,
"firstName": "", "lastName": "", "userName": "",
"password": "", "userSocialAccounts": true, "userPrivacy": "",
"email": "", "bio": "", "profilePicUrl": ""}}

and

{"position": 2, "formula": "sadasd","userId": 3 ,
"firstName": "", "lastName": "", "userName": "",
"password": "", "userSocialAccounts": true, "userPrivacy": "",
"email": "", "bio": "", "profilePicUrl": ""}
 
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either A or B:

A.
1 way to debug is use TCP/IP Mon. Easy setup.

Instead of sending the request to port 8080. You send the request to another port used for TCP/IP Mon.

Use createUser (which is OK) and send the request.
With TCP/IP Mon already set up, you can see the JSON string marshalled via Http body.

Have a look at this correct JSON string and compared with the manually JSON string that caused the 400 reply fron the server.

B.

OR see comment section

 
joseph Williams
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very Much! That should work!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic