none
[E2010] [EWS Java API 1.1][JAVA] - The percentCompleted is not right when creating a task. RRS feed

  • Question

  •  

    Hi,

    I am trying to create task with a non -zero percentage completed value. But when I am retrieving the Task again and checking the percentageComplete.  It is causing some Exception.

     

     

        ExchangeService service = new ExchangeService();
        service.setUrl( new URI( "http://10.192.37.30/ews/Exchange.asmx" ) );
        service.setCredentials( new WebCredentials( "kavya", "P@$$w0rd" ) );
        Collection < Item > items = new ArrayList < Item >();
    
        Task task = new Task( service );
        task.setStartDate( new Date() );
        task.setStatus( TaskStatus.NotStarted );
        task.setPercentComplete( "5.5" );
        task.setImportance( Importance.Normal );
        items.add( task );
        service.setTraceEnabled( true );
        ServiceResponseCollection < ServiceResponse > items2 = service.createItems( items, new FolderId(
            WellKnownFolderName.Tasks ), MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone );
    
        ServiceResponse serviceResponse = items2.getResponseAtIndex( 0 );
        Field itemField = serviceResponse.getClass().getDeclaredField( "item" );
        itemField.setAccessible( true );
        Item item = ( Item ) itemField.get( serviceResponse );
    
        Task retrievedTask = Task.bind( service, item.getId() );
        System.out.println( retrievedTask.getPercentComplete() );

     

     

    The above test case fails with an exception. See below for the trace of the exception.

    Exception in thread "main" microsoft.exchange.webservices.data.ServiceObjectPropertyException: This property was requested, but it wasn't returned by the server.
    	at microsoft.exchange.webservices.data.PropertyBag.getPropertyValueOrException(Unknown Source)
    	at microsoft.exchange.webservices.data.PropertyBag.getObjectFromPropertyDefinition(Unknown Source)
    	at microsoft.exchange.webservices.data.Task.getPercentComplete(Unknown Source)
    	at TestTaskPercentage.main(TestTaskPercentage.java:46)
    

     

    Regards,
    Paul

    Friday, March 4, 2011 9:24 AM

All replies

  • Hi PaulNibin,I wanted to let you know that we have an updated version (1.1.2) available with a change to address your issue "The percent completed is not right when creating a task". Please let us know if you have any questions or problems using the updated version.  Thank you for using EWS Java API and for your feedback!
    Monday, May 23, 2011 3:22 PM