Is it possible to change the PublicId?

Options
markstuartwalker
markstuartwalker Member Posts: 12
edited November 2023 in Developer APIs

I can edit the PublicId but seem not to be able to update it programmatically using NET.

Here is a fragment of my code

UpdateParams up = new UpdateParams(oldPublicId) // tws7/5113_d5240053-1b32-49fd-a11a-400e7a6f5d2e/OriginalWebp
{
    PublicId = newPublicId // tws7/5113_d5240053-1b32-49fd-a11a-400e7a6f5d2e/Original
};
c.cloudinary.UpdateResource(up);


In comparison this works as I would expect

UpdateParams up = new UpdateParams(oldPublicId)
{
    DisplayName = "Original"
};
c.cloudinary.UpdateResource(up);

Is there something that I am missing?

Thanks

Mark

Tagged:

Answers

  • SreeCloudinary
    SreeCloudinary Member, Cloudinary Staff Posts: 26
    Options

    Hi @markstuartwalker,

    Thanks for reaching out.

    Please make use of the rename function call that we have in Upload API as mentioned here in the documentation: https://cloudinary.com/documentation/image_upload_api_reference#rename

    Example:

    RenameParams renameParams = new RenameParams("saroggysyj3haulrxpbj", "Hello_New_Public_ID");

    cloudinary.Rename(renameParams);

    The update call that you are using does not have to public ID option.

    I hope this helps. Please let me know if you have any further questions.

    Best regards,

    Sreenath