OfficeDev / Office-365-SDK-for-iOS

Microsoft Services SDKs for iOS Preview produced by MS Open Tech.
https://dev.office.com/
Other
96 stars 49 forks source link

Send email - Request error 400 #41

Closed dorinsimina closed 9 years ago

dorinsimina commented 9 years ago

When sending an email using the sample I got the following error. Does anyone know why?

Send email: Error Domain=Error in the Request Code=400 "The operation couldn’t be completed. (Error in the Request error 400.)" UserInfo=0x7a770610 {error={ code = ErrorInvalidRequest; message = "Cannot read the request body."; }}

dorinsimina commented 9 years ago

The payload message sent is incorrect when the message does not have any attachment and this causes the error. If I construct manually the call to the REST service it works (by specifying also the attachment field to be nil).

dravva commented 9 years ago

I had hit the similar issue. After debugging, it turned out that passing enum values as integers instead of specific strings was causing the issue. Currently we send "Importance": 1 instead of "Importance": "Normal" which fails. Same with contentType.

{ "Message": { "Subject": "Test subject", "Body": { "ContentType": "Text", "Content": "Test body" }, "Importance": "Normal", "HasAttachments": "false", "IsDeliveryReceiptRequested": "false", "IsReadReceiptRequested": "false", "IsDraft": "false", "IsRead": "false", "ToRecipients": [ { "EmailAddress": { "Address": "xyz@microsoft.com" } } ] }, "SaveToSentItems": "false" }

anihojnadel commented 9 years ago

This issue should be fixed in the new SDK version.

https://github.com/OfficeDev/Outlook-SDK-iOS