I have installed a connected app with the help of a package. And now I want to update it's metadata like 'Canvas App URL' with the help of Metadata API.
First of all, I tried to read all information about the installed connected app via Metadata API. Below is the code to read connected app via Metadata API. All the fields that I am getting in debug are null.
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.ConnectedApp connectedApp =
(MetadataService.ConnectedApp)service.readMetadata('ConnectedApp', new String[] {'MyConnectedApp'}).getRecords()[0];
System.debug(connectedApp);
Below is the debug I am getting.
USER_DEBUG [6]|DEBUG|ConnectedApp:[Metadata.fullName=null, apex_schema_type_info=(http://soap.sforce.com/2006/04/metadata, true, false), attributes=null, attributes_type_info=(attributes, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), canvasConfig=null, canvasConfig_type_info=(canvasConfig, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), contactEmail=null, contactEmail_type_info=(contactEmail, http://soap.sforce.com/2006/04/metadata, null, 1, 1, false), contactPhone=null, contactPhone_type_info=(contactPhone, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), description=null, description_type_info=(description, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), field_order_type_info=(fullName, attributes, canvasConfig, contactEmail, contactPhone, description, iconUrl, infoUrl, ipRanges, label, ...), fullName=null, fullName_type_info=(fullName, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), iconUrl=null, iconUrl_type_info=(iconUrl, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), infoUrl=null, infoUrl_type_info=(infoUrl, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), ipRanges=null, ipRanges_type_info=(ipRanges, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), label=null, label_type_info=(label, http://soap.sforce.com/2006/04/metadata, null, 1, 1, false), logoUrl=null, logoUrl_type_info=(logoUrl, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), mobileAppConfig=null, mobileAppConfig_type_info=(mobileAppConfig, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), mobileStartUrl=null, mobileStartUrl_type_info=(mobileStartUrl, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), oauthConfig=null, oauthConfig_type_info=(oauthConfig, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), plugin=null, plugin_type_info=(plugin, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), samlConfig=null, samlConfig_type_info=(samlConfig, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), startUrl=null, startUrl_type_info=(startUrl, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), type=ConnectedApp, type_att_info=(xsi:type)]
My main purpose is to read the metadata of an installed connected app and update it's canvas app url. I went through all the references available online, but nothing seems helpful right now.
Can this be handled with Canvas Lifecycle Handler class?