Code No Longer Returns Categories

Hello there, I am trying to return categories from the Square API, but for some reason, it is no longer returning categories from the API. It used to work a few months ago, but now, I am not getting anything back. What should I do to fix the issue? Thank you.

public function getCategoryData()
    {
        $accessToken = env('SQUARE_TOKEN');
        $url = 'https://connect.squareup.com/v2/catalog/list';
        //$url = 'https://connect.squareupsandbox.com/v2/catalog/list';

        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Accept' => 'application/json',
        ])->get($url);

        if ($response->successful()) {
            $catalogItems = $response->json()['objects'];
            $categories = [];

            // Iterate over all objects in the API response
            foreach ($catalogItems as $catalogItem) {
                // Check if the object is of type "CATEGORY"
                if ($catalogItem['type'] === 'CATEGORY') {
                    $categoryId = $catalogItem['id'];
                    $categoryName = $catalogItem['category_data']['name'] ?? '';
                    $categoryImageIds = $catalogItem['category_data']['image_ids'] ?? [];

                    if (!is_array($categoryImageIds)) {
                        $categoryImageIds = [];
                    }

                    $images = [];

                    foreach ($categoryImageIds as $imageId) {
                        //$imageUrl = "https://connect.squareupsandbox.com/v2/catalog/object/$imageId";
                        $imageUrl = "https://connect.squareup.com/v2/catalog/object/$imageId";
                        $imageResponse = Http::withHeaders([
                            'Authorization' => 'Bearer ' . $accessToken,
                        ])->get($imageUrl);

                        if ($imageResponse->successful()) {
                            $imageData = $imageResponse->json()['object']['image_data'];
                            $imageUrl = $imageData['url'];
                            $images[] = $imageUrl;
                        } else {
                            $error = $imageResponse->json();
                            info('Error fetching image URL for image ID ' . $imageId . ': ' . json_encode($error));
                        }
                    }

                    // Create a category object with ID and name
                    $category = [
                        'id' => $categoryId,
                        'name' => $categoryName,
                        'image' => $images
                    ];

                    // Add the category object to the categories array
                    $categories[] = $category;
                }
            }

            Log::info('Category Response: ' . json_encode($categories));

            // Return the categories array as JSON response
            return response()->json($categories);
        } else {
            $error = $response->json();
            return response()->json(['error' => $error], $response->status());
        }
    }

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Retrieve Catalog Objects
Search for Items and Objects
Build a Simple Catalog

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

I just tested this and it returned categories for my account. Does the account your using have categories? Are you getting an error or a timestamp in the response? :slightly_smiling_face:

Yeah that’s odd, my log says otherwise. Even though, my log says it returns nothing. I have tested the API on the playground, but it shows the data unlike the console.log. Thank you for the quick response.

local.INFO: Category Response: [] 

Here is the full code if needed.

<?php

namespace App\Http\Controllers;

use Square\SquareClient;
use Square\Environment;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Square\Models\ListLoyaltyRewardsRequest;

class SquareController extends Controller
{
    public function getCatalogItems()
    {
        $accessToken = env('SQUARE_TOKEN');
        $url = 'https://connect.squareup.com/v2/catalog/list';
        //$url = 'https://connect.squareupsandbox.com/v2/catalog/list';

        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Accept' => 'application/json',
        ])->get($url);

        if ($response->successful()) {
            $catalogItems = $response->json();
            return response()->json(['catalog_items' => $catalogItems]);
        } else {
            $error = $response->json();
            return response()->json(['error' => $error], $response->status());
        }
    }

    public function getAllItems()
    {
        $accessToken = env('SQUARE_TOKEN');
        $url = 'https://connect.squareup.com/v2/catalog/list';
        //$url = 'https://connect.squareupsandbox.com/v2/catalog/list';


        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Accept' => 'application/json',
        ])->get($url);

        if ($response->successful()) {
            $catalogItems = $response->json()['objects'];
            $items = [];
            $fillings = [];
            $categories = [];

            foreach ($catalogItems as $catalogItem) {
                if ($catalogItem['type'] === 'CATEGORY') {
                    $categoryId = $catalogItem['id'];
                    $categoryName = $catalogItem['category_data']['name'];
                    $categories[$categoryId] = $categoryName;
                }
            }

            foreach ($catalogItems as $catalogItem) {
                if ($catalogItem['type'] === 'ITEM') {
                    $itemId = $catalogItem['id'];
                    $itemName = $catalogItem['item_data']['name'];
                    $itemDescription = $catalogItem['item_data']['description'] ?? 'No description available';
                    $itemImageIds = $catalogItem['item_data']['image_ids'] ?? [];
                    $itemVariations = $catalogItem['item_data']['variations'];
                    $itemFillingIds = $catalogItem['item_data']['modifier_list_info'] ?? [];
                    $itemCategoryName = [];

                    if (isset($catalogItem['item_data']['categories']) && is_array($catalogItem['item_data']['categories'])) {
                        foreach ($catalogItem['item_data']['categories'] as $category) {
                            $categoryId = $category['id'];
                            $categoryName = $categories[$categoryId] ?? 'Uncategorized';
                            $itemCategoryName[] = $categoryName;
                        }
                    } else {
                        $itemCategoryNames[] = 'Uncategorized';
                    }

                    if (!is_array($itemImageIds)) {
                        $itemImageIds = [];
                    }

                    if (!is_array($itemFillingIds)) {
                        $itemFillingIds = [];
                    }

                    $images = [];

                    foreach ($itemImageIds as $imageId) {
                        //$imageUrl = "https://connect.squareupsandbox.com/v2/catalog/object/$imageId";
                        $imageUrl = "https://connect.squareup.com/v2/catalog/object/$imageId";
                        $imageResponse = Http::withHeaders([
                            'Authorization' => 'Bearer ' . $accessToken,
                        ])->get($imageUrl);

                        if ($imageResponse->successful()) {
                            $imageData = $imageResponse->json()['object']['image_data'];
                            $imageUrl = $imageData['url'];
                            $images[] = $imageUrl;
                        } else {
                            $error = $imageResponse->json();
                            info('Error fetching image URL for image ID ' . $imageId . ': ' . json_encode($error));
                        }
                    }

                    $itemPrice = null;
                    $variationDetails = [];
                    foreach ($itemVariations as $variation) {
                        $variationDetails[] = [
                            'variationId' => $variation['id'],
                            'variationName' => $variation['item_variation_data']['name'],
                            'variationPrice' => $variation['item_variation_data']['price_money']['amount'] ?? 0
                        ];
                        if (isset($variation['item_variation_data']['price_money']['amount'])) {
                            $itemPrice = $variation['item_variation_data']['price_money']['amount'];
                        }
                    }

                    // Get tax rate from Square API
                    $taxRate = $this->getTaxRateFromSquareApi($itemId);
                    Log::info('Tax Rate for item ' . $itemId . ': ' . $taxRate);

                    // Calculate tax amount
                    $taxAmount = ceil(($itemPrice * $taxRate) / 100);
                    Log::info('Tax Amount for item ' . $itemId . ': ' . $taxAmount);

                    $itemFillings = [];
                    foreach ($itemFillingIds as $itemFillingId) {
                        //$modifierUrl = "https://connect.squareupsandbox.com/v2/catalog/object/{$itemFillingId['modifier_list_id']}";
                        $modifierUrl = "https://connect.squareup.com/v2/catalog/object/{$itemFillingId['modifier_list_id']}";
                        $modifierResponse = Http::withHeaders([
                            'Authorization' => 'Bearer ' . $accessToken,
                        ])->get($modifierUrl);
    
                        if ($modifierResponse->successful()) {
                            $modifierListData = $modifierResponse->json()['object']['modifier_list_data'];
                            $modifierListName = $modifierListData['name'];
                            foreach ($modifierListData['modifiers'] as $modifier) {
                                $modifierName = $modifier['modifier_data']['name'];
                                $modifierId = $modifier['id'];
                                $modifierPrice = $modifier['modifier_data']['price_money']['amount'];
                                $itemFillings[] = [
                                    'modifierListName' => $modifierListName,
                                    'modifierId' => $modifierId,
                                    'modifierName' => $modifierName,
                                    'modifierPrice' => $modifierPrice
                                ];
                            }
                        } else {
                            $error = $modifierResponse->json();
                            info('Error fetching modifier list for modifier list ID ' . $itemFillingId['modifier_list_id'] . ': ' . json_encode($error));
                        }
                    }
                    Log::info('Item Fillings', ['itemFillings' => $itemFillings]);
    

                    $items[] = [
                        'id' => $itemId,
                        'name' => $itemName,
                        'description' => $itemDescription,
                        'price' => $itemPrice,
                        'tax_amount' => $taxAmount,
                        'tax_rate' => intval($taxRate),
                        'images' => $images,
                        'variations' => $variationDetails,
                        'fillings' => $itemFillings,
                        'categories' => $itemCategoryName
                    ];
                }
            }

            Log::info('Items:', $items);

            return response()->json($items);
        } else {
            $error = $response->json();
            Log::info('Error:', $error);
            return response()->json(['error' => $error], $response->status());
        }
    }

    
    private function getTaxRateFromSquareApi($itemId)
    {
        // Debug statement to verify method invocation
        Log::info('getTaxRateFromSquareApi called for item ID: ' . $itemId);
    
        $accessToken = env('SQUARE_TOKEN');
        $url = "https://connect.squareup.com/v2/catalog/object/$itemId";
        //$url = "https://connect.squareupsandbox.com/v2/catalog/object/$itemId";
    
        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Accept' => 'application/json',
        ])->get($url);
    
        if ($response->successful()) {
            $itemData = $response->json()['object'];
            $taxRateId = $itemData['item_data']['tax_ids'][0] ?? null;
    
            if ($taxRateId) {
                Log::info('Tax Rate Id: ' . $taxRateId);
    
                // Get tax rate details from Square API
                $taxRateDetails = $this->getTaxRateDetailsFromSquareApi($taxRateId);
    
                if ($taxRateDetails) {
                    Log::info('Tax Rate Details: ' . json_encode($taxRateDetails));
    
                    $taxPercentage = $taxRateDetails['percentage'] ?? 0;
                    return intval($taxPercentage);
                } else {
                    Log::info('Tax Rate details not found for tax ID: ' . $taxRateId);
                }
            } else {
                Log::info('No tax rate ID found for item ID: ' . $itemId);
            }
        } else {
            $error = $response->json();
            Log::info('Error fetching tax rate for item ID ' . $itemId . ': ' . json_encode($error));
        }
    
        // Default to 0 if there's an error or tax rate is not found
        return 0;
    }

    private function getTaxRateDetailsFromSquareApi($taxRateId)
{
    $accessToken = env('SQUARE_TOKEN');
    $url = "https://connect.squareup.com/v2/catalog/object/$taxRateId";
    //$url = "https://connect.squareupsandbox.com/v2/catalog/object/$taxRateId";


    $response = Http::withHeaders([
        'Authorization' => 'Bearer ' . $accessToken,
        'Accept' => 'application/json',
    ])->get($url);

    if ($response->successful()) {
        return $response->json()['object']['tax_data'];
    } else {
        $error = $response->json();
        Log::error('Error fetching tax rate details for tax rate ID ' . $taxRateId . ': ' . json_encode($error));
        return null;
    }
}

    

    

    public function getItemData(Request $request, $itemId)
    {
        $accessToken = env('SQUARE_TOKEN');
        $url = 'https://connect.squareup.com/v2/catalog/list';
        //$url = 'https://connect.squareupsandbox.com/v2/catalog/list';

        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Accept' => 'application/json',
        ])->get($url);

        if ($response->successful()) {
            $catalogItems = $response->json()['objects'];

            // Search for the item with the given ID
            foreach ($catalogItems as $catalogItem) {
                if ($catalogItem['type'] === 'ITEM' && $catalogItem['id'] === $itemId) {
                    $itemName = $catalogItem['item_data']['name'];

                    // Initialize itemDescription
                    $itemDescription = '';

                    // Extract description from variations
                    $itemDescription = $catalogItem['item_data']['description'] ?? 'No description available';

                    // Extract price from the first variation
                    $itemPrice = $catalogItem['item_data']['variations'][0]['item_variation_data']['price_money']['amount'] ?? null; // Assuming single variation

                    $itemImageIds = $catalogItem['item_data']['image_ids'] ?? [];

                    return response()->json([
                        'name' => $itemName,
                        'description' => $itemDescription,
                        'price' => $itemPrice,
                        'image_ids' => $itemImageIds,
                    ]);
                }
            }

            return response()->json(['error' => 'Item not found.'], 404);
        } else {
            $error = $response->json();
            return response()->json(['error' => $error], $response->status());
        }
    }

    public function getCategoryData()
    {
        $accessToken = env('SQUARE_TOKEN');
        $url = 'https://connect.squareup.com/v2/catalog/list';
        //$url = 'https://connect.squareupsandbox.com/v2/catalog/list';

        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Accept' => 'application/json',
        ])->get($url);

        if ($response->successful()) {
            $catalogItems = $response->json()['objects'];
            $categories = [];

            // Iterate over all objects in the API response
            foreach ($catalogItems as $catalogItem) {
                // Check if the object is of type "CATEGORY"
                if ($catalogItem['type'] === 'CATEGORY') {
                    $categoryId = $catalogItem['id'];
                    $categoryName = $catalogItem['category_data']['name'] ?? '';
                    $categoryImageIds = $catalogItem['category_data']['image_ids'] ?? [];

                    if (!is_array($categoryImageIds)) {
                        $categoryImageIds = [];
                    }

                    $images = [];

                    foreach ($categoryImageIds as $imageId) {
                        //$imageUrl = "https://connect.squareupsandbox.com/v2/catalog/object/$imageId";
                        $imageUrl = "https://connect.squareup.com/v2/catalog/object/$imageId";
                        $imageResponse = Http::withHeaders([
                            'Authorization' => 'Bearer ' . $accessToken,
                        ])->get($imageUrl);

                        if ($imageResponse->successful()) {
                            $imageData = $imageResponse->json()['object']['image_data'];
                            $imageUrl = $imageData['url'];
                            $images[] = $imageUrl;
                        } else {
                            $error = $imageResponse->json();
                            info('Error fetching image URL for image ID ' . $imageId . ': ' . json_encode($error));
                        }
                    }

                    // Create a category object with ID and name
                    $category = [
                        'id' => $categoryId,
                        'name' => $categoryName,
                        'image' => $images
                    ];

                    // Add the category object to the categories array
                    $categories[] = $category;
                }
            }

            Log::info('Category Response: ' . json_encode($categories));

            // Return the categories array as JSON response
            return response()->json($categories);
        } else {
            $error = $response->json();
            return response()->json(['error' => $error], $response->status());
        }
    }

    public function getAllRewards()
    {
        $accessToken = env('SQUARE_TOKEN');
        $client = new SquareClient([
            'accessToken' => $accessToken,
            'environment' => Environment::PRODUCTION,
        ]);
    
        $user = Auth::user();
        $loyaltyAccountId = $user->loyalty_account_id;
    
        try {
            // Step 1: Fetch the loyalty program
            $programResponse = Http::withHeaders([
                'Authorization' => 'Bearer ' . $accessToken,
                'Accept' => 'application/json',
            ])->get("https://connect.squareup.com/v2/loyalty/programs");
    
            Log::info('Loyalty Program Response:', ['response' => $programResponse->json()]);
    
            if ($programResponse->successful()) {
                $program = $programResponse->json()['programs'][0] ?? null; // Adjust based on response structure
    
                if (!$program) {
                    return response()->json(['error' => 'No main loyalty program found.'], 404);
                }
    
                // Step 2: Fetch the customer's loyalty account
                $accountResponse = Http::withHeaders([
                    'Authorization' => 'Bearer ' . $accessToken,
                    'Accept' => 'application/json',
                ])->get("https://connect.squareup.com/v2/loyalty/accounts/{$loyaltyAccountId}");
    
                Log::info('Loyalty Account Response:', ['response' => $accountResponse->json()]);
    
                if ($accountResponse->successful()) {
                    $account = $accountResponse->json()['account'] ?? null;
    
                    if (!$account) {
                        return response()->json(['error' => 'No loyalty account found for the customer.'], 404);
                    }
    
                    $customerPoints = $account['balance'] ?? 0;
    
                    // Step 3: Compare customer's points with reward tiers
                    $availableRewards = [];
    
                    if (isset($program['reward_tiers']) && count($program['reward_tiers']) > 0) {
                        foreach ($program['reward_tiers'] as $rewardTier) {
                            $pointsRequired = $rewardTier['points'];
    
                            if ($customerPoints >= $pointsRequired) {
                                $availableRewards[] = [
                                    'rewardName' => $rewardTier['name'],
                                    'pointsRequired' => $pointsRequired,
                                    'discountType' => $rewardTier['definition']['discount_type'] ?? '',
                                    'discountValue' => $rewardTier['definition']['percentage_discount'] ?? 0,
                                    'maxDiscount' => $rewardTier['definition']['max_discount_money']['amount'] ?? 0,
                                ];
                            }
                        }
    
                        if (count($availableRewards) > 0) {
                            Log::info('Available Rewards:', $availableRewards);
                            return response()->json(['data' => $availableRewards], 200);
                        } else {
                            Log::info('No rewards available for the customer\'s current points.');
                            return response()->json(['error' => 'No rewards available based on the current points.'], 404);
                        }
                    } else {
                        Log::warning('No reward tiers found in the loyalty program.');
                        return response()->json(['error' => 'No reward tiers found in the program.'], 404);
                    }
                } else {
                    Log::error('Failed to fetch customer loyalty account:', ['error' => $accountResponse->json()]);
                    return response()->json(['error' => 'Failed to fetch customer loyalty account.'], 400);
                }
            } else {
                Log::error('Failed to fetch loyalty program:', ['error' => $programResponse->json()]);
                return response()->json(['error' => 'Failed to fetch loyalty program.'], 400);
            }
        } catch (\Exception $e) {
            Log::error('Exception fetching loyalty program or rewards:', ['exception' => $e->getMessage()]);
            return response()->json(['error' => 'An error occurred while fetching loyalty data.'], 500);
        }
    }
    


}

What’s your application ID? :slightly_smiling_face:

sq0idp-yBm9s6Y7ecMUsLnnkVBZLg

Now I manage to get the categories to display, now the issue is that I cannot get them to be initialized for certain items despite the playground showing that the category_ids exist and connected.

 public function getAllItems()
    {
        $accessToken = env('SQUARE_TOKEN');
        $url = 'https://connect.squareup.com/v2/catalog/list';

        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Accept' => 'application/json',
        ])->get($url);

        if ($response->successful()) {
            $catalogItems = $response->json()['objects'];
            $items = [];
            $categories = [];

            // Step 1: Fetch all categories
            foreach ($catalogItems as $catalogItem) {
                if ($catalogItem['type'] === 'CATEGORY') {
                    $categoryId = $catalogItem['id'];
                    $categoryName = $catalogItem['category_data']['name'] ?? 'Uncategorized';
                    $categories[$categoryId] = $categoryName;

                    \Log::info("Fetched Category: ID = $categoryId, Name = $categoryName");
                }
            }

            foreach ($catalogItems as $catalogItem) {
                if ($catalogItem['type'] === 'ITEM') {
                    $itemId = $catalogItem['id'];
                    $itemName = $catalogItem['item_data']['name'];
                    $itemDescription = $catalogItem['item_data']['description'] ?? 'No description available';
                    $itemImageIds = $catalogItem['item_data']['image_ids'] ?? [];
                    $itemVariations = $catalogItem['item_data']['variations'];
                    $itemCategoryNames = [];
                    $itemFillingIds = $catalogItem['item_data']['modifier_list_info'] ?? [];

                    $categoryIds = [];

                    if (isset($catalogItem['item_data']['categories']) && is_array($catalogItem['item_data']['categories'])) {
                        foreach ($catalogItem['item_data']['categories'] as $category) {
                            if (isset($category['id'])) {
                                $categoryIds[] = $category['id'];
                            }
                        }
                    }

                    if (isset($catalogItem['item_data']['category_id'])) {
                        $categoryIds[] = $catalogItem['item_data']['category_id'];
                    }

                    if (isset($catalogItem['item_data']['reporting_category']['id'])) {
                        $categoryIds[] = $catalogItem['item_data']['reporting_category']['id'];
                    }

                    foreach ($categoryIds as $categoryId) {
                        if ($categoryId && isset($categories[$categoryId])) {
                            $itemCategoryNames[] = $categories[$categoryId];
                        }
                    }

                    if (empty($itemCategoryNames)) {
                        $itemCategoryNames[] = 'Uncategorized';
                        \Log::warning("Item ID $itemId has no valid category. Defaulting to 'Uncategorized'.");
                    }

                    $images = [];
                    foreach ($itemImageIds as $imageId) {
                        $imageUrl = "https://connect.squareup.com/v2/catalog/object/$imageId";
                        $imageResponse = Http::withHeaders([
                            'Authorization' => 'Bearer ' . $accessToken,
                        ])->get($imageUrl);

                        if ($imageResponse->successful()) {
                            $imageData = $imageResponse->json()['object']['image_data'];
                            $images[] = $imageData['url'];
                        }
                    }

                    $variationDetails = [];
                    foreach ($itemVariations as $variation) {
                        $variationDetails[] = [
                            'variationId' => $variation['id'],
                            'variationName' => $variation['item_variation_data']['name'],
                            'variationPrice' => $variation['item_variation_data']['price_money']['amount'] ?? 0,
                        ];
                    }

                    $items[] = [
                        'id' => $itemId,
                        'name' => $itemName,
                        'description' => $itemDescription,
                        'images' => $images,
                        'variations' => $variationDetails,
                        'categories' => implode(', ', $itemCategoryNames),
                    ];
                }
            }
            \Log::debug("Item ID: $itemId, Categories Array: ", $catalogItem['item_data']['categories'] ?? []);
            \Log::debug("Mapped Categories: ", $itemCategoryNames);

            return response()->json($items);
        } else {
            return response()->json(['error' => $response->json()], $response->status());
        }
    }

LOG:

[2024-12-19 19:45:12] local.WARNING: Item ID SBRLGWK5OGPWDPBZV7KGMHUO has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID LJT4B3INQUNLFVOZEQODU72T has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID HWOYP3K5GIDPTTJFFGQC7FEX has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID DDRDG3LAU6HQKFJDHPMHL3W6 has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID 63ZG52GVONGHYOOXEI3JCNEO has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID DEL3GNWLQUKFPUXYHP4J6URU has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID NW236M5DB4XDBL4CPELRDVK4 has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID Z5VRPV2MNTOHGKIA74SKAP4I has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID 4VXMXKHL23LZBIFELLN2BMWN has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID IRMS57FQRPTW6JGD5KIW2VII has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.WARNING: Item ID LAIY2U6EBXWVZ6RIZNPOFVBO has no valid category. Defaulting to 'Uncategorized'.  
[2024-12-19 19:45:12] local.DEBUG: Item ID: LAIY2U6EBXWVZ6RIZNPOFVBO, Categories Array:  [{"id":"H3SQWB6NEYXAPTMF3H5VSDOM","ordinal":-2250150546243584}] 

Are the categories that’s associated to the items the reporting category? :slightly_smiling_face:

Based on several items shown on the Square API Background, yes they are.

When you say initialize what do you mean? I took a look at the API logs and I see the items in your list being returned. :slightly_smiling_face:

So I want to initialize the categories names with the items. I want to get the category ids so that I can search up the category name and initialize it to there. I want to make it where people can select a certain drink. There should be a tab called “Iced Drinks” and should display a list of drinks that are in the category Iced Drinks. But, when I tested out the app a few months later, it is no longer working and now puts everything on “Uncategorized”.

I’m a bit confused because you start by listing the category and then get the items. If you’ve started with the category then you have the name of the category. :slightly_smiling_face: