I'm getting an internal server error for Parameter name: key
when trying to update a calendar appointment.
It 'cannot be null'. What can this mean? There is no parameter 'key'. Is 
the value being reported on?
When browsing around on SO for Parameter name 'key' cannot be null I get the idea it could be a programming error in Exchange Server itself.
select @@version
gives:
Microsoft SQL Server 2016 (SP1-CU2) (KB4013106) - 13.0.4422.0 (X64)
Mar 6 2017 14:18:16
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: ) (Hypervisor)
This is the response:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="2814" MinorBuildNumber="22" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</s:Header>
<s:Body>
<m:UpdateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:UpdateItemResponseMessage ResponseClass="Error">
<m:MessageText>An internal server error occurred. The operation failed., Value cannot be null.
Parameter name: key</m:MessageText>
<m:ResponseCode>ErrorInternalServerError</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items/>
</m:UpdateItemResponseMessage>
</m:ResponseMessages>
</m:UpdateItemResponse>
</s:Body>
</s:Envelope>
to this request:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
<typ:RequestServerVersion Version="Exchange2010"/>
<typ:MailboxCulture>en-US</typ:MailboxCulture>
<typ:TimeZoneContext>
<typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
</typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
<mes:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone">
<mes:ItemChanges>
<typ:ItemChange>
<typ:ItemId Id="AQMkAGMz[snip]AAAA==" ChangeKey="DwAA[snip]JuniP+" />
<typ:Updates>
<typ:SetItemField>
<typ:FieldURI FieldURI="item:Subject"/>
<typ:CalendarItem>
<typ:Subject>Gewijzigde afspraak? Ik denk het wel</typ:Subject>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="item:Sensitivity"/>
<typ:CalendarItem>
<typ:Sensitivity>Normal</typ:Sensitivity>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="item:Categories"/>
<typ:CalendarItem>
<typ:Categories>
<typ:String>TimeTell</typ:String>
</typ:Categories>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="item:Body"/>
<typ:CalendarItem>
<typ:Body BodyType="Text">Aangemaakt door Wendy</typ:Body>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="calendar:Location"/>
<typ:CalendarItem>
<typ:Location></typ:Location>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="calendar:IsAllDayEvent"/>
<typ:CalendarItem>
<typ:IsAllDayEvent>false</typ:IsAllDayEvent>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="calendar:Start"/>
<typ:CalendarItem>
<typ:Start>2020-03-31T16:56:27.929+02:00</typ:Start>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="calendar:End"/>
<typ:CalendarItem>
<typ:End>2020-03-31T17:56:27.929+02:00</typ:End>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="calendar:LegacyFreeBusyStatus"/>
<typ:CalendarItem>
<typ:LegacyFreeBusyStatus>Busy</typ:LegacyFreeBusyStatus>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="calendar:StartTimeZone"/>
<typ:CalendarItem>
<typ:StartTimeZone TimeZoneName="W. Europe Standard Time"/>
</typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
<typ:FieldURI FieldURI="calendar:EndTimeZone"/>
<typ:CalendarItem>
<typ:EndTimeZone TimeZoneName="W. Europe Standard Time"/>
</typ:CalendarItem>
</typ:SetItemField>
</typ:Updates>
</typ:ItemChange>
</mes:ItemChanges>
</mes:UpdateItem>
</soapenv:Body>
</soapenv:Envelope>
Wow, this was really unpredictable.
I had replaced the THTTPReqResp
components, with TipwHTTP
from nSoftware's IPWorks. This uses all ordinary String types.
But the data sent to EWS needs to be UTF-8
After all we say ContentType := 'text/xml; charset=utf-8'
*.
After the conversion my code still reads:
lHTTP.PostData := FSoapRequest; // A string type
but it should be:
lHTTP.PostDataB := BytesOf(UTF8Encode(FSoapRequest)); // UTF8Encode returns a UTF-8 encoded RawByteString with a code page of CP_UTF8 (65001) assigned to it.
I found this out by carefully looking at the SOAP calls that failed. They contained things like the Word 'Left single quotation mark' (U-2018, people just copy/paste Word texts in to email), or even the simple diacritics like é and ü, that caused these errors.
* Yes, the 'utf-8' without quotes, because that's what Exchange Webservices wants
Notes: