'Update foreign key in Spring Boot with a POST request

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.



Solution 1:[1]

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.

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexander Ivanchenko
Solution 2