+ Start a Discussion
Prashant InamdarPrashant Inamdar 

Error in updating Zuora subscription using Apex code

Hi,
I am trying to update zuora subscription from apex code.
I have imported zuora api WSDL and got the classes created.
Getting below error.
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: invalid type: zObjects faultcode=fns:INVALID_TYPE faultactor=
apiZuoraCom.LoginResult zresult;
            List<apiZuoraCom.SaveResult> RetResult= new List<apiZuoraCom.SaveResult>();
            List<objectApiZuoraCom.zObject> ParaSub= new List<objectApiZuoraCom.zObject>();
            objectApiZuoraCom.zObject zobj= new objectApiZuoraCom.zObject();
            objectApiZuoraCom.subscription zsub= new objectApiZuoraCom.subscription();
            apiZuoraCom.Soap apiZuoraComsoapobj = New apiZuoraCom.Soap();
            apiZuoraComsoapobj.SessionHeader = new apiZuoraCom.SessionHeader_element();
                        
            zobj.id = '2c92c0f856300a60015630f641217d71';
            ParaSub.add(zobj);
            
            zresult = apiZuoraComsoapobj.login('user_name', 'password');
                       
            apiZuoraComsoapobj.SessionHeader.session= zresult.Session; 
            
            System.debug(apiZuoraComsoapobj.SessionHeader.session );

            RetResult = apiZuoraComsoapobj.update_x(ParaSub);

 
SFDC_BigDogSFDC_BigDog
List<Zuora.zObject> zuoraSubscriptionsetting = new List<Zuora.zObject>();

 Zuora.zApi zApidfrty = new Zuora.zApi();

 Zuora.zObject zSubtrrty = new Zuora.zObject('Subscription');

 zSubtrrty.setValue('Id', zq[0].zqu__ExistSubscriptionID__c); 
 zSubtrrty.setValue('PreviewedTax__c','0.00' ); 
 zuoraSubscriptionsetting.add(zSubtrrty);              
                          
 try {
        if (!Test.isRunningTest()) 
          {
          zApidfrty.zlogin();
          }
         } catch (Exception e) 
         {
            System.debug('Exception while logging in: ' + e.getMessage());
         }
                                  

            if (!zuoraSubscriptionsetting.isEmpty()) {
             System.debug(zuoraSubscriptionsetting);
              List<Zuora.zApi.SaveResult> SubscriptionUpdateResults = new List<Zuora.zApi.SaveResult>();
               try {
                    if (!Test.isRunningTest()) {
                         SubscriptionUpdateResults = zApidfrty.zUpdate(zuoraSubscriptionsetting);
                      }
                       } catch (Exception e) {
                          System.debug('Exception while updating Subscription: ' + e.getMessage());
                        }

                          System.debug('Subscripton Account Results: ' + SubscriptionUpdateResults);
                           } else 
                           {
                              System.debug('Zuora Subscription to update does not exist.');
                            }
@Prashant

I have also worked on Zuora for Salesforce. In the API call for updating the subscription in Zuora. I have done similar to this. Please try if this helps to you. Let me know if you have any more questions