At this time a upc isn’t supported in sandbox through the import which is why your getting empty results in sandbox. If the items would have been created with the API then a upc would be in the object in sandbox. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. For production I just ran:
var objectTypes = new List<string>();
objectTypes.Add("ITEM");
objectTypes.Add("ITEM_VARIATION");
var prefixQuery = new CatalogQueryPrefix.Builder(attributeName: "upc", attributePrefix: "000000120001")
.Build();
var query = new CatalogQuery.Builder()
.PrefixQuery(prefixQuery)
.Build();
var body = new SearchCatalogObjectsRequest.Builder()
.ObjectTypes(objectTypes)
.IncludeDeletedObjects(false)
.IncludeRelatedObjects(true)
.Query(query)
.Build();
try
{
var result = await client.CatalogApi.SearchCatalogObjectsAsync(body: body);
}
catch (ApiException e)
{
Console.WriteLine("Failed to make the request");
Console.WriteLine($"Response Code: {e.ResponseCode}");
Console.WriteLine($"Exception: {e.Message}");
}
and got back:
{
"objects": [
{
"type": "ITEM_VARIATION",
"id": "KISWM3UUEFHD7V5DE4S3NP4J",
"updated_at": "2022-10-26T18:06:43.307Z",
"created_at": "2021-04-21T19:18:16.198Z",
"version": 1666807603307,
"is_deleted": false,
"present_at_all_locations": true,
"item_variation_data": {
"item_id": "DGGLQEOSHV4DONXMZNT6UF4T",
"name": "Regular",
"sku": "918535L",
"upc": "000000120001",
"ordinal": 1,
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 149,
"currency": "USD"
},
"location_overrides": [
{
"location_id": "LQD712KXKAKJ7",
"track_inventory": true
}
],
"sellable": true,
"stockable": true,
"item_variation_vendor_info_ids": [
"NXWQYJ7BKWSQLAG2M6CBB66I"
]
}
}
],
"related_objects": [
{
"type": "ITEM",
"id": "DGGLQEOSHV4DONXMZNT6UF4T",
"updated_at": "2022-10-26T18:06:43.307Z",
"created_at": "2021-04-21T19:18:16.198Z",
"version": 1666807603307,
"is_deleted": false,
"present_at_all_locations": true,
"item_data": {
"name": "Unisex Socks",
"visibility": "PRIVATE",
"category_id": "OTPEVBSRK362H2SFOSHRLLKK",
"tax_ids": [
"4TAGTIBG7JS5YMJD4FGWWCQT"
],
"variations": [
{
"type": "ITEM_VARIATION",
"id": "KISWM3UUEFHD7V5DE4S3NP4J",
"updated_at": "2022-10-26T18:06:43.307Z",
"created_at": "2021-04-21T19:18:16.198Z",
"version": 1666807603307,
"is_deleted": false,
"present_at_all_locations": true,
"item_variation_data": {
"item_id": "DGGLQEOSHV4DONXMZNT6UF4T",
"name": "Regular",
"sku": "918535L",
"upc": "000000120001",
"ordinal": 1,
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 149,
"currency": "USD"
},
"location_overrides": [
{
"location_id": "LQD712KXKAKJ7",
"track_inventory": true
}
],
"sellable": true,
"stockable": true,
"item_variation_vendor_info_ids": [
"NXWQYJ7BKWSQLAG2M6CBB66I"
]
}
}
],
"product_type": "REGULAR",
"skip_modifier_screen": false,
"ecom_uri": "https://that-one-store.square.site/product/unisex-socks/302",
"ecom_available": true,
"ecom_visibility": "VISIBLE"
}
}
],
"latest_time": "2022-12-07T19:37:09.495Z"
}
In sandbox you can search by sku which for this item would be 918535L. I confirmed it’s visible in sandbox and is returned if you change upc to sku for testing purposes. 