2

I'm trying to update a connected app programatically using MetadataService framwork. I have no problem with create and delete connected app. Here is my code :

public class UpdateConnectedApps {
public static MetadataService.MetadataPort createService() {
      MetadataService.MetadataPort service = new MetadataService.MetadataPort();
      service.SessionHeader = new MetadataService.SessionHeader_element();
      service.SessionHeader.sessionId = UserInfo.getSessionId();
      service.timeout_x = 40000;
      return service;
  }

    public static void updateConnectedApps() {
    MetadataService.MetadataPort service = createService();

    //build
    MetadataService.ConnectedApp build = new MetadataService.ConnectedApp();
    build.contactEmail = '[email protected]';
    build.fullName = 'build2019aaa';
    build.label = 'ConnectedAppToUpdate';
    build.description = 'description';
    MetadataService.ConnectedAppOauthConfig buildo = new MetadataService.ConnectedAppOauthConfig();
    buildo.consumerKey = 'XXX';
    buildo.consumerSecret = 'VVV';
    buildo.callbackUrl = 'https://eu16.lightning.force.com';
    buildo.scopes = new List<String>();
    buildo.scopes.add('Full');
    buildo.scopes.add('RefreshToken');
    build.oauthConfig = buildo;
    List<MetadataService.UpsertResult> buildresults = service.upsertMetadata(
          new MetadataService.Metadata[] { build });


  }
}

When I try to use it with comand in console, i have this error :

FATAL_ERROR System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 586433682-45351 (1280375022) faultcode=sf:UNKNOWN_EXCEPTION faultactor=

Is there anything wrong?

1
  • I would try taking out the consumer key and consumer secret, since those aren't going to change anyways and they aren't writeable. Maybe that's what is throwing an error Dec 21, 2021 at 22:40

0

You must log in to answer this question.

Browse other questions tagged .