MarketplaceService:getProductInfo() failed because HTTP 400 (Bad Request)

I’m trying to make a script which automatically creates an entry in a Shop GUI, showing the robux price and the in-game coin price of the object. It cycles through every article within game.ServerStorage.Monetization.Gears using for i,v in pairs. Although, on the first cycle, I get this error:

MarketplaceService:getProductInfo() failed because HTTP 400 (Bad Request)

Here is the snippet

for i, iteminshop in pairs(shopItems1) do
	
	local ID = iteminshop.ID.Value -- Represents the ID of the gamepass
	
	local info = Market:GetProductInfo(ID, Enum.InfoType.Product) -- THE LINE WHICH PRODUCES THE ERROR
	
	if info then
		robuxprice = info.PriceInRobux
	else
		print ("Could not assign price! - " .. iteminshop.Name)
	end
	
	local item = toEdit.Frame.UICorner.Item:Clone()
	local RentPrice = iteminshop:FindFirstChild("RentPrice")
	
	item.Name = iteminshop.Name
	item.RobuxPrice.Text = robuxprice
	item.Title.Text = iteminshop.Name
	item.Image.Image = iteminshop.TextureId

	item.Parent = shopFrame
	item.Click.Enabled = true
	
	if RentPrice then
		item.RentPrice.Text = iteminshop.Price.Value
	else
		item.Coin:Destroy()
		item.RentPrice:Destoy()
	end
end

I have HTTP requests turned on in game settings although the error persits, what should I do?

1 Like

That error means that the product doesn’t exist, might be an incorrect ID?

You could wrap it in a pcall to avoid the error and continue with existing IDs:

pcall(function()
    --| Code He
end)
1 Like

try printing out the id to see if something is wrong with it. I don’t see a reason why it should not work

2 Likes

I found one of the IDs was false and replaced it with the correct it, though the error still persists.

I also do need the ID so as to generate the object’s robux price as it causes this error further down the line:

Unable to assign property Text. string expected, got nil  -  Server - GamepassSetup:45

The ID prints perfectly fine and when copying and pasting it into Roblox it sends me to the correct article (being 675816735 for the first run through)

1 Like

Line 5, change Enum.InfoType.Product to Enum.InfoType.GamePass

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.