Hey! How do i need get gamepass or dev product icon?
There is a code that i have rn:
function module.getProductURL(Info)
local success, productURL = pcall(function()
local assetId = Info.ProductId
local URL = HttpService:GetAsync(`https://www.roproxy.com/asset-thumbnail/image?assetId={assetId}&size=420x420&format=png`)
return HttpService:JSONDecode(URL)
end)
if success and productURL then
productURL = productURL["data"][1].imageUrl
else
productURL = `https://tr.rbxcdn.com/180DAY-1104aaa4ec1b610e9b576ab9dc0b924a/420/420/Decal/Webp/noFilter`
end
return productURL
end
SOLVED
The code that i used:
local success, productURL = pcall(function()
local assetId = Info.ProductId -- change to Gamepass id or Developer Product id
local Info = MarketplaceService:GetProductInfo(assetId, Enum.InfoType.GamePass) -- Change Enum.InfoType.GamePass to Enum.InfoType.Product if you need
local URL = HttpService:GetAsync(`https://thumbnails.roproxy.com/v1/assets?assetIds={Info["IconImageAssetId"]}&returnPolicy=PlaceHolder&size=420x420&format=png`) -- Getting main URL to icon
return HttpService:JSONDecode(URL) -- Decode and returning
end)
if success and productURL then
productURL = productURL["data"][1].imageUrl
else
productURL = `https://tr.rbxcdn.com/180DAY-1104aaa4ec1b610e9b576ab9dc0b924a/420/420/Decal/Webp/noFilter` -- Image if asset icon not foundede
end
Externally, you can use the https://thumbnails.roblox.com/v1/batch endpoint. Worth noting that developer products have two internal IDs, you can’t use the normal ID that Roblox normally provides you.
so im just need to use https://apis.roblox.com/developer-products/v1/developer-products/{RobloxProvidedID}/details to get icon?
and what is RobloxProvidedId? like just id of Developer Product?
local success, productURL = pcall(function()
local assetId = Info.ProductId -- change to Gamepass id or Developer Product id
local Info = MarketplaceService:GetProductInfo(assetId, Enum.InfoType.GamePass) -- Change Enum.InfoType.GamePass to Enum.InfoType.Product if you need
local URL = HttpService:GetAsync(`https://thumbnails.roproxy.com/v1/assets?assetIds={Info["IconImageAssetId"]}&returnPolicy=PlaceHolder&size=420x420&format=png`) -- Getting main URL to icon
return HttpService:JSONDecode(URL) -- Decode and returning
end)
if success and productURL then
productURL = productURL["data"][1].imageUrl
else
productURL = `https://tr.rbxcdn.com/180DAY-1104aaa4ec1b610e9b576ab9dc0b924a/420/420/Decal/Webp/noFilter` -- Image if asset icon not foundede
end
Oops, my bad, I forgot that this exists in Roblox XD
But, in any case, I still have a problem with GamePasses…
When I use my code, everything works fine when the webhook sends the image, but when the GamePasses sends the image, it returns an error in the output, and the image appears as a “error” image in Discord.
Sorry for asking another question, but I’m having some trouble…
When I try to purchase a Developer Product, the webhook can’t find productURL[“data”][1].imageUrl (i.e., there’s no productURL[“data”] or the table is empty).
I’ll assume the product doesn’t have an image, in which case you should just return nothing. I think it’s if IconImageAssetId == 0 or nil.
If it’s something else, like random errors, not sure I’d need more specifics. You should add checks, e.g. if productURL.data and productURL.data[1] and productURL.data[1].imageUrl then
local _errorImage = `https://tr.rbxcdn.com/180DAY-1104aaa4ec1b610e9b576ab9dc0b924a/420/420/Decal/Webp/noFilter`
local success, productURL = pcall(function()
local URL = HttpService:GetAsync(`https://thumbnails.roproxy.com/v1/assets?assetIds={Info.IconImageAssetId}&returnPolicy=PlaceHolder&size=420x420&format=png`)
return HttpService:JSONDecode(URL)
end)
if success and productURL then
local data = productURL["data"]
if #data > 0 then
productURL = productURL["data"][1].imageUrl
else
productURL = _errorImage
end
else
productURL = _errorImage
end
return productURL