0

I am trying to build a book your meeting application using exchange 2010 in Android. I am using CorporateContacts to familiarise myself with activesync. I have managed to get ResolveRecipients , SendMail and FolderSync commands working so far. However when I am trying to upload a meeting request I am getting a 400 Bad Request Error. I am using this as reference.

My xml

<?xml version="1.0" encoding="utf-8"?>
<Sync xmlns:calendar="Calendar" xmlns="AirSync">
    <Collections>
        <Collection>
            <SyncKey>1425334024</SyncKey>
            <CollectionId>4</CollectionId>
            <GetChanges>1</GetChanges>
            <Commands>
                <Add>
                    <ClientId>5644895</ClientId>
                    <ApplicationData>
                         <calendar:TimeZone>tv7//ygAVQBUAEMAKwAwADUAOgAzADAAKQAgAEMAaABlAG4AbgBhAGkALAAgAEsAbwBsAGsAYQB0AGEALAAgAE0AdQAAAAAAAAAAAAAAAAAAAAAAAAAAACgAVQBUAEMAKwAwADUAOgAzADAAKQAgAEMAaABlAG4AbgBhAGkALAAgAEsAbwBsAGsAYQB0AGEALAAgAE0AdQAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</calendar:TimeZone>
                        <calendar:StartTime>20130109T100000Z</calendar:StartTime>
                        <calendar:Subject>TestMeeting</calendar:Subject>
                        <calendar:UID>040000008200E90074C5B7101A82E0080000000036BD76EAAAD5CA01000000000000000010000000C45185F686A5D542B20BF2CE2F477D55</calendar:UID>
                        <calendar:Attendees>
                            <calendar:Attendee>
                                <calendar:Email>Test@test.com</calendar:Email>
                                <calendar:Name>JohnDoe</calendar:Name>
                                <calendar:AttendeeStatus>0</calendar:AttendeeStatus>
                                <calendar:AttendeeType>1</calendar:AttendeeType>
                            </calendar:Attendee>
                        </calendar:Attendees>
                        <calendar:Location>My Office</calendar:Location>
                        <calendar:EndTime>20130109T110000Z</calendar:EndTime>
                        <calendar:Sensitivity>0</calendar:Sensitivity>
                        <calendar:BusyStatus>1</calendar:BusyStatus>
                        <calendar:AllDayEvent>0</calendar:AllDayEvent>
                        <calendar:MeetingStatus>1</calendar:MeetingStatus>
                    </ApplicationData>
                </Add>
            </Commands>
        </Collection>
    </Collections>
</Sync>

The CreateHTTPPost function

private HttpPost createHttpPost(String uri, String requestXML,
            boolean includePolicyKey) throws Exception {

        // Set the common headers
        HttpPost httpPost = new HttpPost(uri);
        httpPost.setHeader("User-Agent", "Android");
        httpPost.setHeader("Accept", "*/*");
        httpPost.setHeader("Content-Type", "application/vnd.ms-sync.wbxml");
        //httpPost.setHeader("Content-Type", "message/rfc822");//message/rfc822



        // If we are connecting to Exchange 2010 or above
        // Lets tell the Exchange server that we are a 12.1 client
        // This is so we don't have to support sending of additional
        // information in the provision method
        if(getActiveSyncVersionFloat() >= 14.0)
            httpPost.setHeader("MS-ASProtocolVersion", "12.1");
        // Else set the version to the highest version returned by the
        // Exchange server
        else
            httpPost.setHeader("MS-ASProtocolVersion", getActiveSyncVersion());


        //Log.d(TAG, mActiveSyncVersion);
        httpPost.setHeader("Accept-Language", "en-us");
        httpPost.setHeader("Authorization", mAuthString);

        // Include policy key if required
        if (includePolicyKey)
            httpPost.setHeader("X-MS-PolicyKey", mPolicyKey);

        // Add the XML to the request
        if (requestXML != null) {
            //Log.d(TAG, requestXML);
            // Set the body
            // Convert the XML to WBXML
            ByteArrayInputStream xmlParseInputStream = new ByteArrayInputStream(
                    requestXML.toString().getBytes());

            java.io.ByteArrayOutputStream output = new java.io.ByteArrayOutputStream();
            wbxml.convertXmlToWbxml(xmlParseInputStream, output);
            byte[] bytes = output.toByteArray();

            ByteArrayEntity myEntity = new ByteArrayEntity(bytes);
            myEntity.setContentType("application/vnd.ms-sync.wbxml");
            httpPost.setEntity(myEntity);
        }
        return httpPost;
    }

Is there any headers I am missing ? OR Any error with the xml? I will be extremely obliged if somebody can throw some light. I am using activesync version 12.1 in headers.

windwaker
  • 315
  • 3
  • 12
  • Never used this but that double slash in your calendar:TimeZone in the xml would be where I would look. – Kevin D Jan 07 '13 at 13:08
  • This is the timezone value I got from the server when I synced the calendar folder. Even If i remove the timezone field I still get the same error :( – windwaker Jan 08 '13 at 12:18

1 Answers1

0

The xml looks fine. Make sure you are properly converting to wbxml from xml. To double check try converting back to xml and see if you get back the original string.