Rename based off fileKey

Hey, I am trying to get the rename api request to work. I'm getting a 400 syntax error: here's my call: {fileKey: "FLqidTvfTRqGKM6ccn4qVLgD7WCkX1pG5EIv42Pt8a093mYQ", newName: "Earnings_Statement-USDA.png"}
const result = await utapi.renameFiles({
fileKey: metadata.fileKey,
newName: metadata.newName,
})
const result = await utapi.renameFiles({
fileKey: metadata.fileKey,
newName: metadata.newName,
})
Here's the file's JSON:
{
"name": "DOS LandE Statement.png",
"key": "FLqidTvfTRqGygjB79lIeSvmNzVXcYsKalt9BfAkM7dGhWgP",
"customId": null,
"url": "https://2jestdr1ib.ufs.sh/f/FLqidTvfTRqGygjB79lIeSvmNzVXcYsKalt9BfAkM7dGhWgP",
"size": 150449,
"uploadedAt": "2025-01-24T15:38:11.000Z"
}
]
{
"name": "DOS LandE Statement.png",
"key": "FLqidTvfTRqGygjB79lIeSvmNzVXcYsKalt9BfAkM7dGhWgP",
"customId": null,
"url": "https://2jestdr1ib.ufs.sh/f/FLqidTvfTRqGygjB79lIeSvmNzVXcYsKalt9BfAkM7dGhWgP",
"size": 150449,
"uploadedAt": "2025-01-24T15:38:11.000Z"
}
]
I'm getting a 404 syntax error when I'm calling my rename function. I have also tried replacing fileKey with key, with the same error. (I also want to potentially avoid this as I might have multiple files with the same name and different keys.) What could be the issue?
3 Replies
Gold240sx
Gold240sxOP2mo ago
Anyone?…
mukomo
mukomo2mo ago
Your file key in the json object above and the key in the file json lower don't match
Gold240sx
Gold240sxOP2mo ago
Thanks. I got it working.

Did you find this page helpful?