none
Office365 Calendar API - Create fails returning : "ErrorInvalidIdMalformed : Id is malformed". RRS feed

  • Question

  • Create calendar fails - trying to create a calendar under a calendar group. 

    Even though, am able to manually create a calendar under the CalendarGroup by logging into the account using a browser, am not able to do the same via API. 

    When I tried hitting the API, got the following error back : "ErrorInvalidIdMalformed : Id is malformed". This seems to happen even with very basic sample payload 'Name' of the calendar to be created.

    It used to work fine until couple of weeks back. 

    NOTE ***** Initial investigation looks like, it mostly concerned with predefined/default calendars that come up with the office365 account : Ex: My Calendars, People Calendars, Other Calendars. Using API, am not able to POST Create a calendar with the above error.


    Wednesday, March 7, 2018 7:25 AM

All replies

  • I am seeing the exact same issue calling a POST command to create a Calendar.

    We can successfully make GET calls against the following URL:

    https://outlook.office.com/api/v2.0/users/{user_name}/calendargroups?$filter=Name eq 'CalGroup'

    We get back a response that resembles the following (key fields edited):

    [{u'ClassId': u'{class_id}',
      u'Name': u'CalGroup', 
      u'ChangeKey': u'{change_key}',
      u'@odata.id': u"https://outlook.office.com/api/v2.0/Users('{user_guid}')/CalendarGroups('calgroup_id')",
      u'Id': u'{calgroup_id}'
    }]

    We then try and use that Id field in the response to make a POST call against that calendar group ID to create a calendar and get the above ErrorInvalidIdMalformed error in response:

    url_cg = "https://outlook.office.com/api/v2.0/users/{username}/calendargroups/{calgroup_id}/calendars"
    
    post(url_cg, data={'Name': 'deleteme'})
    
    {u'error': {u'message': u'Id is malformed.', u'code': u'ErrorInvalidIdMalformed'}}

    This was working a couple of weeks back for us, but as of recently these calls are failing.

    Wednesday, March 7, 2018 10:53 PM
  • I'm also seeing the exact same issue in a multi-tenant application that I am currently working on.

    I have confirmed that this error happens on both the Microsoft Graph and Outlook API endpoints.

    I think it may be related to the type of base64 decoding that is being done on the API endpoint, because I was able to get the API to work by replacing all instances of '_' with '+' in one of the IDs. This workaround does not work if the ID contains a '-' character, in which case I have found no way around the error.

    Here is a reproduction of the problem using the Python shell:

    import api
    
    >>> url = "https://outlook.office.com/api/v2.0/users/auser@adomain.com/calendargroups"
    >>> response = api.get(url)
    >>> response
    [{
        u'ClassId': u'bf22395d-e505-4f58-8504-6e6e8ef8c3c7', 
        u'Name': u'My Calendar Group', 
        u'ChangeKey': u'g4QAQQ9PZUGX1I2OsM9/LgAAA0km+g==', 
        u'@odata.id': u"https://outlook.office.com/api/v2.0/Users('46560569-3535-441e-9bcf-eb093a992360@767316c0-7a9b-4a7c-95e9-5490466be3f0')/CalendarGroups('AAMkAGVmNzJkNGNiLWE4YmYtNDQ2NC1iOGJiLWI5ZmFlYzgyNzVmYgBGAAAAAAC3biJFdLv_S7D_aGLbIKWwBwCDhABBD09lQZfUjU6wz38uAAAAAAEGAACDhABBD09lQZfUjU6wz38uAAADSL12AAA=')", 
        u'Id': u'AAMkAGVmNzJkNGNiLWE4YmYtNDQ2NC1iOGJiLWI5ZmFlYzgyNzVmYgBGAAAAAAC3biJFdLv_S7D_aGLbIKWwBwCDhABBD09lQZfUjU6wz38uAAAAAAEGAACDhABBD09lQZfUjU6wz38uAAADSL12AAA='
    }]
    
    
    >>> calendargroup_id = response[0]['Id']
    >>> url += "/%s/calendars" % calendargroup_id
    >>> url
    "https://outlook.office.com/api/v2.0/users/auser@adomain.com/calendargroups/AAMkAGVmNzJkNGNiLWE4YmYtNDQ2NC1iOGJiLWI5ZmFlYzgyNzVmYgBGAAAAAAC3biJFdLv_S7D_aGLbIKWwBwCDhABBD09lQZfUjU6wz38uAAAAAAEGAACDhABBD09lQZfUjU6wz38uAAADSL12AAA=/calendars"
    
    >>> api.get(url) // This API call succeeds. It successfully tells us that this calendargroup contains no calendars. In other words it is able to identify the calendargroup using the calendargroup_id we send it.
    []
    
    >>> api.post(url, data={'Name': 'New Calendar'}) // This is the failing API call. If we try to do a POST request in order to create a new calendar, the API can no longer parse our id, and complains:
    {u'error': {u'message': u'Id is malformed.', u'code': u'ErrorInvalidIdMalformed'}}

    Saturday, March 10, 2018 3:11 AM
  • I got this error too. In my case It was silly mistake, I was using dynamic url and was using wrong url..
    Wednesday, November 14, 2018 10:08 AM