When I implemented this function and tested it out, it output the wrong asset id endpoint. It was a decal asset id I copied from the creator page and I made sure the decal was public as well. It gave me the rbxassetid format when it should be the roblox.com one. Any ideas on why this is?
The way the code works is to assume that a failure to insert means that it was already an image and not a decal. However, technically there are some other rare backend failures which could happen. If you care about fixing the last 0.1% or whatever edge case you could attempt to parse the error message and determine what the error is (4xx error vs 5xx error), but the error messages arenât guaranteed to stay the same so that would require more maintenance of the code.
TL;DR: You probably got very unlucky and there was a backend failure on that particular request.
Ah, yeah, it probably would have been good to put a check in the sample code that itâs being run on the server to avoid confusion because the pcall will mask the error if you do it on the client.