• 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

Why can't I insert a Foreign Key into my table with JSON on Postman?

 
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two entities, Vehicle and Owner.  The Vehicle has a foreign key that references the owner of that vehicle, and whenever I try to post a foreign key to reference the owner_id for the vehicle, it gives me an error.  


{
   "timestamp": "2020-11-22T23:48:27.344+00:00",
   "status": 400,
   "error": "Bad Request",
   "message": "",
   "path": "/addVehicle"
}

It lets me add a vehicle, but only when the owner ID is null.   When I go directlly to the MySQL query on phpMyAdmin and type it in by inserting into the table using the SQL syntax, it works fine.  
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed the syntax to the right way to add a foreign key, but it is coming up null.
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured it out, I had insertable= false in my code which was impacting it.  
 
reply
    Bookmark Topic Watch Topic
  • New Topic