Has the `SearchCatalogItemsRequest` class been removed?


I was wondering if the class SearchCatalogItemsRequest has been removed. It seems as if my IDE can only find SearchCatalogObjectsRequest:

This is despite the fact that I can definitely find the class in the source code of the JDK, which I have separately downloaded. It is under the models subpackage, where SearchCatalogObjectsRequest also resides.

My relevant Square version is, as betrayed by the pom file:


Hi @JasonFil welcome to the forums!

Not sure how you see it in the code, as the SearchCatalogItems endpoint wasn’t made available until 2020-07-22 (which in Java is You can see that here in the release notes: https://github.com/square/square-java-sdk/releases.

Oh wow, I was using an old version in my pom. Thank you, I see it now.

// Additionally, we will leave the fact that I used the same variable name for the purported name of this object as the name of a parameter alone.

1 Like

Ha, no worries at all :slight_smile: . Let me know if you have any other questions of course.

1 Like

Another one came to mind. In my application, I guarantee that CatalogItem and CatalogItemVariation IDs are unique. If I want to search for a CatalogItem or CatalogItemVariation based on its (unique) ID - let’s call it searchableID - I would not use textFilter(), but rather categoryIds(), correct? That is, I should do this:

SearchCatalogItemsRequest squareAPIRequest =
				new SearchCatalogItemsRequest
					.textFilter(Collections.singletonList(searchableID))    // A singleton list consisting of the single ID I want to search on.

instead of this:

SearchCatalogItemsRequest squareAPIRequest =
				new SearchCatalogItemsRequest

Right? It appears to me that textFilter() will succeed, but it might return a result set with instances that have a substring similar to the ID that I’m using, which is otherwise guaranteed unique per CatalogObject I create. So I will be getting lots of potentially irrelevant answers.

Hm, I might be misunderstanding so apologies ahead of time, if so.

If you know the catalog object id (regardless if it’s an item or a variation), you can simply retrieve it using RetrieveCatalogObject (or BatchRetrieveCatalogObjects if you have several to retrieve). The categoryIds you mentioned, is actually a great way to find all items of a particular category (ex: give me all the items in the “Beverage” category), but not a great way to find a particular single object/item. Likewise, textFilter would be if you do not know the ID, and need to search by something else (say the variation name, or the SKU).

I understand now, I did not know that retrieval methods existed alongside search methods. It makes linguistic sense, too. Thank you.

When using retrieveCatalogObjectAsync (or not Async), if the query simply fails because there is no ID of the one provided, does this mean that the relevant Object field in the response structure will be a null reference?

If a retrieve fails due to an object not existing, then it would be the API Exception, since this would be a 404 not found, not a successful response.