-1

I have a hook, and I want to get the external_id. Could you please help me? which event do I need to use to get the external_id?

2 Answers2

1

There is a method to details of an item https://developers.podio.com/doc/items/get-item-22360

Here I have attached the code example of Java SDK. Hope it helps

enter image description here

import java.io.Serializable;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.podio.app.AppAPI;
import com.podio.app.ApplicationField;
import com.podio.common.Reference;
import com.podio.common.ReferenceType;
import com.podio.contact.Profile;
import com.podio.file.FileAPI;
import com.podio.item.FieldValuesUpdate;
import com.podio.item.FieldValuesView;
import com.podio.item.ItemAPI;
import com.podio.item.ItemBadge;
import com.podio.item.ItemCreate;
import com.podio.item.ItemUpdate;
import com.podio.item.ItemsResponse;
import com.podio.oauth.OAuthClientCredentials;
import com.podio.oauth.OAuthUsernameCredentials;
import com.podio.task.Task;
import com.podio.task.TaskAPI;
import com.podio.user.UserAPI;


public class APICall implements Serializable {
    public static void main(String as[]){
        APICall  apiObj =  new APICall();
        apiObj.apicall();
    }

    /**
     * 
     */
    public void  apicall()
    {
        try{
            System.out.println("inside");

            ResourceFactory resourceFactory = new ResourceFactory(new OAuthClientCredentials("<your app name>","<your client secret>"),new OAuthUsernameCredentials("<user_name>", "<password>"));
            //List<filters>
            ItemAPI itapi = new ItemAPI(resourceFactory);
            ItemsResponse itres =itapi.getItems(<item_id>, null, null, null, null, null);
            List<ItemBadge> li= itres.getItems();

            for (ItemBadge ib : li ){
                List<FieldValuesView> listvals =ib.getFields();

                for (FieldValuesView val : listvals ){
                    System.out.println(val.getValues()+"--"+val.getExternalId());
                }



                FileAPI fapi = new FileAPI(resourceFactory);
                java.io.File file = new java.io.File("/Users/brijeshluckria/Downloads/Contacts - All Contacts.xlsx");

                System.out.println(file.getAbsolutePath()+"::"+file.exists());

                int id=fapi.uploadFile("Apifile",file);
                System.out.println("ids"+id);
priya lingam
  • 164
  • 4
  • Hello priya, I forgot to tell, the hook that I create it's in php. – Vicky A. Sep 14 '16 at 02:16
  • I use this https://developers.podio.com/doc/hooks .The hooks trigger when you update/create an item, I want to know which field(external_id) was updated – Vicky A. Sep 14 '16 at 02:16
1

external_id parameter is sent for item.create and item.update hooks. In order to have it sent, item needs to have it :)

So, if you just create item from Podio web, that item won't have any external_id. But if you create item via API and specify external_id then it will be there. Here is full example in Ruby:

attr = {:fields => { :title => 'Created with external ID'},
        :external_id => 'exernal_id_for_demo' }
item = Podio::Item.create(app_id, attr)

Then webhook item.create will be:

item_id: 720040614
item_revision_id: 0
type: item.create
hook_id: 7243151
external_id: exernal_id_for_demo

When item doesn't have external_id then when webhook is invoked you will only get an item_id as a POST parameter. Use this to make an API request to get the item the webhook was called on and then you can get all item details. You can also get item revisions to see which field was updated.

You can also create couple of different webhooks for different fields.
As documentation says: Additionally, the three hooks item.create, item.update and item.delete can also work on a field level. If you use "app_field" as the ref_type and an app field_id as the ref_id your hook will only be triggered if the changes happen to that particular field.

Then your webhooks will only be triggered when specific field was modified, but I would still recommend to go with getItem and getRevisions path.

Pavlo - Podio
  • 2,003
  • 2
  • 10
  • 19