#muhammet-product-list

1 messages ยท Page 1 of 1 (latest)

languid barnBOT
tired yacht
shy hound
#

I had no problems with the build process. I'm having a problem retrieving an existing product in bulk using its ids.
const products = await stripe.products.list({
limit: 3,
});
I want to get product details by using this method with id's. How should I create an object?

tired yacht
#

I'm sorry, I'm not sure I'm understanding the question. You're trying to use the ids parameter that is available for that function, but are running into problems doing so?

shy hound
#

I want to get multiple items using only ids

tired yacht
#

Gotcha, so it sounds like you're trying to figure out what the syntax should be to use that ids parameter.

shy hound
#

Yes, I tried many things but it didn't work.

tired yacht
#

I was able to put the product IDs in a list, like this:

  limit: 3,
  ids: ['prod_abc','prod_def']
});```
shy hound
#

I'm sorry, it doesn't work.

#

PROD LIST { object: 'list', data: [], has_more: false, url: '/v1/products' }

tired yacht
#

Can you share the ID of the request (req_123) that didn't work?

shy hound
#

There are no logs. Actually, our request works, but it does not bring the products.

tired yacht
#

There is still a log for the request that you can view in the Stripe dashboard. Did you replace the placeholder values in the snippet that I provided with real IDs matching your Product objects?

opal needle
#

๐Ÿ‘‹ I'm stepping in for my teammate! Let me know if you have a request ID handy, or if you can share your Stripe account ID. Your account ID should look like acct_...

#

If you're testing out this request using curl, your request would look like this:
curl -G https://api.stripe.com/v1/products -u sk_test_... -d ids[]=prod_... -d ids[]=prod_...

shy hound
#

I think I found my mistake. I don't create a product at checkout. It comes when I call single. My multiple calls are called from the product list that I have already created. But since I do not create the products, naturally, no product comes. What I don't understand is that the product arrives in my single calls.

#

By the way my id: acct_1LYZHXG7TiqQhuQ2

opal needle
#

Thanks! I think I understand what's happening. I see that Checkout Sessions are being created, and you're using line_items.price_data to pass along amount, currency etc.

shy hound
#

Yes

opal needle
#

I don't think I follow this:

What I don't understand is that the product arrives in my single calls.

#

can you clarify what you mean by this?

#

Note that a Product will also be created based on the values you pass in line_items.price_data.product_data. If you don't want to create a new Product, you should pass in a product ID as the value of line_items.price_data.product instead

shy hound
#

When I make a request like this, this result comes

#

However, when I want to do this in bulk, it returns an empty array.

opal needle
#

do you get any data if you omit the second ID from that array?

opal needle
#

I'm not able to reproduce this, unfortunately. I'm using the same syntax on my end

fading crater
#

muhammet-product-list

#

@shy hound it's because you're on an old API version

#

ah you seem to use the latest API version, so print how many elements you have in productsList.data