Patch credentials endpoint

May I ask why is the /rest/credentials/:id endpoint checking for an existing credential?
// Check if credentials with the same name and type exist already
const findQuery = {
where: {
id: Not(id),
name: incomingData.name,
type: incomingData.type,
},
} as FindOneOptions;
How do you then patch, if you are not proceeding if credential exists?

Welcome to the community @pedrocacho!

That is needed because else it would be possible to have two credentials of the same type with the same name. Because of the id: Not(id), part it excludes the one that gets currently processed and it can so be saved.

Why is it that you cannot edit the credential instead of making a new one?

Sorry but do not understand the question. It is editing the exiting one. You should probably have another look at the code and check what exactly it is doing.

@pedrocacho did you check the code and is now every clear? If not tell me then I can try to help you.

hi jan, i just do not understand why there is such an error being thrown: Credentials with the same type and name exist already for this user.

if you are patching the credential should it not be editing an existing one? so this error doesn’t make sense to me, because the user should be able to edit an existing one with the same name and type

Yes exactly. If you “edit” an existing one via the UI that will work fine.

If you, however, create a “new” one and you choose the exact same name as one which exists already with the same type, it will throw this error.

For “create” and “edit” two different endpoints get used. I did never have any issues with it nor did I ever hear of other users having issues. Can you please tell me exactly what you are doing as I do not understand right now why it would not work for you? Thanks!