Home > database >  Update foreign key in Spring Boot with a POST request
Update foreign key in Spring Boot with a POST request

Time:05-16

I am trying to make a put request using Postman with Spring Boot. The idea is to give the subscription object a foreign key value with a put request or post.

I get this errorerror

Postman input : INPUT

The user class : User

The subscription class : Subscription

Update method : Update

I've already searched the internet and I didn't find anything useful.

CodePudding user response:

Your Controller path in the image is subscription/{id} and you're trying to request user/{id}. As far as I understand, you're requesting the wrong URL.

By the way, when you're performing multiple interactions with the Database, use @Transactional annotation.

CodePudding user response:

When i read your code, what you trying to is getting the data from client Entity then save toSubscription Entity if Exist using PUT as update . How about make validation of Client for Post mapping if meet the requirement then save it also to Subscription.

  • Related