Search code examples
exchange-serverhttp-status-code-400

Getting (400) Bad Request error while using GetAttachment command to download an attachment from Exchange Server 2010


Following is my request header :

POST [Server]/Microsoft-Server-ActiveSync?Cmd=GetAttachment&AttachmentName=5%3a1%3a0&User=[user]&DeviceId=[DeviceId]&DeviceType=[DeviceType] HTTP/1.1
Content-Type: application/vnd.ms-sync.wbxml
Authorization: Basic [credentials]
MS-ASProtocolVersion: 12.1
User-Agent: MSFT-WP/8.0.10211
X-MS-PolicyKey: [PolKey]
Host: [host]
Content-Length: 0

I'm trying to download the attachment of an email, returned through the sync command as follows:

  <Attachment>
    <DisplayName>ATT00001.txt</DisplayName>
    <FileReference>5%3a1%3a0</FileReference>
    <Method>1</Method>
    <EstimatedDataSize>29406</EstimatedDataSize>
  </Attachment>

The server supports the 12.1 protocol. I have spent my last two days on this without any luck. Any help would be appreciated.


Solution

  • Got the problem just now. So basically as this request didn't had any payload, so no content-type should have been specified in the first place.