Post

1 follower Follow
0
Avatar

Java API Item request

Have anybody some example java api code for returning all items in a application

Jeroen Tip Answered

Please sign in to leave a comment.

13 comments

0
Avatar

We have a lot of java samples at https://github.com/podio, but I just went through them and ironically they all seem to be creating items, not reading items.

Even if it's not exactly what you asked for, perhaps these samples will be able to help you:

https://github.com/podio/sample-alerts/blob/master/src/main/java/com/podio/sample/alert/AlertWriter.java

https://github.com/podio/sample-dropbox/blob/master/src/main/java/com/podio/sample/dropbox/FileScanner.java

https://github.com/podio/sample-zendesk/blob/master/src/main/java/com/podio/sample/zendesk/Importer.java

Casper Fabricius 0 votes
0
Avatar

I have reed the code alredy however this is al getting items by external id

I am trying to use the following code 

    ItemsResponse items =  itemAPI.getItems(1663074, 20, 0, null, true, null);

getting errors with this one.

I just need a simple list of items in the application with there ID is there another way to get them ?

Jeroen Tip 0 votes
0
Avatar

this is the exeption

start ITEM

c1connect

i1Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at com.podio.item.ItemAPI.getItems(ItemAPI.java:281)

at nl.docuproces.addpodiolink.Podioconnect.getItems(Podioconnect.java:135)

at nl.docuproces.addpodiolink.Cache.cache_dpItem(Cache.java:108)

at nl.docuproces.addpodiolink.SelectPodioItem$5.itemStateChanged(SelectPodioItem.java:297)

at javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1225)

at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1282)

at javax.swing.JComboBox.contentsChanged(JComboBox.java:1329)

at javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:118)

at javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.java:94)

at javax.swing.JComboBox.setSelectedItem(JComboBox.java:578)

at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:624)

at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:835)

at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)

at java.awt.Component.processMouseEvent(Component.java:6505)

at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)

at com.apple.laf.AquaComboBoxPopup$1.processMouseEvent(AquaComboBoxPopup.java:157)

at java.awt.Component.processEvent(Component.java:6270)

at java.awt.Container.processEvent(Container.java:2229)

at java.awt.Component.dispatchEventImpl(Component.java:4861)

at java.awt.Container.dispatchEventImpl(Container.java:2287)

at java.awt.Component.dispatchEvent(Component.java:4687)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)

at java.awt.Container.dispatchEventImpl(Container.java:2273)

at java.awt.Window.dispatchEventImpl(Window.java:2719)

at java.awt.Component.dispatchEvent(Component.java:4687)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)

at java.awt.EventQueue.access$000(EventQueue.java:102)

at java.awt.EventQueue$3.run(EventQueue.java:662)

at java.awt.EventQueue$3.run(EventQueue.java:660)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)

at java.awt.EventQueue$4.run(EventQueue.java:676)

at java.awt.EventQueue$4.run(EventQueue.java:674)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

Jeroen Tip 0 votes
0
Avatar

So this should work?

ItemsResponse items = itemAPI.getItems(2100929, 100, 0, null, false);

I get this exception

Exception in thread "main" APIException [status=Bad Request, error=invalid_value, description=Invalid value 0: Must not be less than 1 (at limit), parameters=null]

    at com.podio.ExceptionFilter.handle(ExceptionFilter.java:27)

    at com.sun.jersey.api.client.Client.handle(Client.java:648)

    at com.podio.LoginFilter.handle(LoginFilter.java:28)

    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670)

    at com.sun.jersey.api.client.WebResource.get(WebResource.java:191)

    at com.podio.item.ItemAPI.getItems(ItemAPI.java:285)

    at def.start.main(start.java:34)

Rich Stoldt 0 votes
0
Avatar

The error message is from the API saying the limit was set to 0. However from your code the limit should be set to 100. Are you sure your code is exactly like that? 

Christian Holm 0 votes
0
Avatar

Oops - never mind ... apparently Eclipse doesn't save the file prior to running.  Any example on how to iterate through the ItemsResponse object?

Rich Stoldt 0 votes
0
Avatar

Could you share the solution here so people coming back at a later date can see what was going on?

Andreas Haugstrup Pedersen 0 votes
0
Avatar

Certainly - I'm just a bit shy since I'm such a noob .... I'll throw in iterating the fields as a bonus :)

Perhaps you might demonstrate a filter for the getItems method in return.

        ItemAPI itemAPI = apiFactory.getAPI(ItemAPI.class);

        ItemsResponse response = itemAPI.getItems(2100929, 100, 0, null, false);

        System.out.println(response.toString());

        List<ItemBadge> items = response.getItems();

        for (ItemBadge item : items)

        {

            List<FieldValuesView> fields = item.getFields();

            for (FieldValuesView field : fields)

            {

                System.out.println(field.getLabel().toString());

                System.out.println(field.getValues().toString());

            }

        }

Rich Stoldt 0 votes
0
Avatar
ItemsResponse response = itemAPI.getItems(podioAppId, 100, 0, null, false);

When i execute the this code i got the following exception. Does anybody knows whats the problem. What exactly are the inside parameters ?

com.sun.jersey.api.client.ClientHandlerException: org.codehaus.jackson.map.JsonMappingException: No enum constant com.podio.app.ApplicationFieldType.PHONE (through reference chain: com.podio.item.ItemsResponse["items"]->com.podio.item.ItemBadge["fields"]->com.podio.item.FieldValuesView["type"])
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:644)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:586)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:686)
at com.sun.jersey.api.client.WebResource.get(WebResource.java:193)
at com.podio.item.ItemAPI.getItems(ItemAPI.java:294)

Deepak R Babu 0 votes