Read and Write via Edges (Create Objects)
mainEdges represent relationships in the Graph API.
Reading Edges: Use the getter for the edge (e.g., account.getCampaigns()) to retrieve a list of related objects.
Writing Edges: To create a new object under a parent, use the createXXX() method on the parent object (e.g., account.createCampaign()).
Note on Creation: The create call typically only returns the ID of the new object. To populate the object with data, call .fetch() immediately after.
// Reading an edge
AdAccount account = new AdAccount(ACCOUNT_ID, context);
APINodeList<Campaign> campaigns = account.getCampaigns().requestAllFields().execute();
// Writing (creating) an object via an edge
Campaign campaign = account.createCampaign()
.setName("Java SDK Test Campaign")
.setObjective(Campaign.EnumObjective.VALUE_LINK_CLICKS)
.execute();
// Fetch the newly created object to get its full data
campaign.fetch();