PUT method not updating object

0
Hello, I’m trying to update an entity ‘AppUser’ by and external source which uses the PUT or POST method through API. I have been successfull in setting up the GET method to retrieve info based on a key value but I can’t figure out how I can  update a user. These are my current configurations: PRS     MF Import mapping With this setup I get this in my SwaggerUI:   I can still retrieve users from the database with the key value (mpleoid) but when i change something in the ApplicationUserParams, it doesn’t update the user. It will create the object if the user doesn’t exist, however you must fill in all the mapped values or it won’t create the object. When deploying this setup to production and doing tests through postman, I am able to retrieve an appuser through the key value but whenever i add the body to the http requests and try to update an existing user/create a new user , nothing happens. How could I reconfigure my setup to make it so that when you have a PUT request with an existing key value, it updates according to the body inputted and am able to update seperate values? How could i reconfigure my setup to make it so that when you have a PUT request with a new key value, it creates the object according to the body inputted?   Thanks
asked
1 answers
0

Hi Eson,

There's quite a lot to unpack here. I suggest that you use the debugger together with the variables tab to walk through your microflows step by step to investigate what they are doing. It can really help you get an understanding of what is actually happening when you execute a microflow.

There's no inherent difference between PUT and GET statements. They are a bit different in their setup, but if you execute the same microflow, they will do the same thing. So you have to adjust your microflow have them do what you want them to do.

Since you are mapping to a persistent object, finding them by key, it will look in the database if it can find a user for that key. This means that the object you are looking for is already mapped to the ApplicationUser parameter. The retrieve that you do in the microflow will likely result in a duplicate object.

What you can do, is check if the ApplicationUser parameter is empty. If it is, the object is not empty, it means the user exists and you can commit that object. It should update with the new body (not 100% about this, but it should work). In your import mapping, you can also configure what it should do if it can't find an existing object. You can tell it to create a new object. All you have to do then is commit the ApplicationUserParams object, and it should work just like that.

Hope that helps.

answered