question

billy-watkins avatar image
billy-watkins asked Raymond Lee Deactivated edited

Client Exception when creating category using sdk

We are trying to create items and assign them to a new category using the sdk.
However we are having issues when creating a new category without a helpful error message

Category newCategory = new Category();
newCategory.setName("TokenPrinter");
mInventoryConnector.createCategory(newCategory);

this throws a client exception:
statusCode = UNKNOWN; 
statusMessage = null
if instead I use:

Category newCategory = new Category();
mInventoryConnector.createCategory(newCategory);
this throws a client exception
statusCode = 400; 
statusMessage = Invalid category:Name is required to be non-null

But as you can see from the first attempt providing a name does not resolve the issue and there is no follow up message.

Any Light you can shed on this would be appreciated.

Clover Android SDKInventory
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Raymond Lee avatar image
Raymond Lee Deactivated answered Raymond Lee Deactivated edited
I was able to reproduce your issue, and looking at the exception, it complains about the Category's Items being null.

I have filed a ticket for this, as ideally it should just create an empty ArrayList of Items for you, if you do not set one.

For now the workaround would be to create an empty ArrayList and pass it into the Category object.

                Category newCategory = new Category();
                newCategory.setName("New Category");
                newCategory.setItems(new ArrayList<Reference>());
                mInventoryConnector.createCategory(newCategory);
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lee Tickett avatar image Lee Tickett commented ·

Thanks Raymond, works a treat. When you say "looking at the exception, it complains about the category's items being null" could you elaborate on how/where you saw this exception? As Billy mentioned, we just got the 400 error "Invalid category:Nameis required to be non-null".

1 Like 1 ·
Raymond Lee avatar image Raymond Lee Lee Tickett commented ·

Great to hear it works! The null items exception was from using the first code snippet Bill provided:

Category newCategory = new Category();
newCategory.setName("TokenPrinter");
mInventoryConnector.createCategory(newCategory);

The exception shows up before the ClientException Bill mentioned:

07-16 14:42:15.287 1739-1921/? E/JavaBinder: *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
    android.database.sqlite.SQLiteConstraintException: category.items may not be NULL (code 19)
0 Likes 0 ·

Welcome to the
Clover Developer Community