1

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 = 'test@test.com';
    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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.