ios - Exchange ActiveSync Objective-C Provision Command Bad Request -
i have spent days of trial , error, looked through exchange logs, , searched on internet , far unable resolve issue.
i implementing activesync capabilities within ios app , far have coded autodiscover process , http options request server's capabilities. trying run provision command keep getting 400 bad request.
here sending server:
url: https://mobile.[myexchangeserver].com/microsoft-server-activesync?cmd=provision&user=jack&deviceid=123412341234&devicetype=ios authorization = "basic wekrju283j"; //base 64 encoded auth, garbage posting "content-length" = 104; "content-type" = "application/vnd.ms-sync.wbxml"; "ms-asprotocolversion" = "12.1"; "user-agent" = myapp; "x-ms-policykey" = 0; body (converted wbxml before sending): <?xml version="1.0" encoding="utf-8"?> <provision xmlns="provision:"> <policies> <policy> <policytype>ms-eas-provisioning-wbxml</policytype> </policy> </policies> </provision> wbxml: 02 00 25 6a 41 50 72 6f 76 69 73 69 6f 6e 00 50 6f 6c 69 63 69 65 73 00 50 6f 6c 69 63 79 00 50 6f 6c 69 63 79 54 79 70 65 00 2d 2f 2f 41 49 52 53 59 4e 43 2f 2f 44 54 44 20 41 69 72 53 79 6e 63 2f 2f 45 4e 00 44 00 44 0a 44 13 44 1a 03 4d 53 2d 45 41 53 2d 00 83 00 03 69 6e 67 2d 57 42 58 4d 4c 00 01 01 01 01
is there anyway can find out more "bad request"? or see wrong i'm sending in? server supports 12.1 protocol (from options request)
i've read through protocol documentation on , on , still can't find wrong i'm doing. know can base64 encode paramaters, according protocl docs optional. know in 14.1 need send more information in xml, hence why i'm using 12.1 protocol.
any appreciated.
nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:uri cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:300.0]; nsstring *msglength = [nsstring stringwithformat:@"%d",[requestbodydata length]]; nslog(@"request body data length: %@",msglength); [request sethttpmethod:@"post"]; [request setvalue:mauthstringfinal forhttpheaderfield:@"authorization"]; [request setvalue:@"iphone" forhttpheaderfield:@"devicetype"]; [request setvalue:@"application/vnd.ms-sync.wbxml" forhttpheaderfield:@"content-type"]; [request setvalue:msglength forhttpheaderfield:@"content-length"]; [request setvalue:@"12.1" forhttpheaderfield:@"ms-asprotocolversion"]; [request setvalue:@"*/*" forhttpheaderfield:@"accept"]; [request setvalue:@"en-us" forhttpheaderfield:@"accept-language"]; [request setvalue:nil forhttpheaderfield:@"x-ms-policykey"]; [request sethttpbody:requestbodydata]; nsurlconnection *connection = [[nsurlconnection alloc]initwithrequest:request delegate:self]; /* ensure connection created */ if (connection) { /* initialize buffer */ buffer = [nsmutabledata data]; /* start request */ [connection start]; } else { nslog(@"connection failed"); }
i have added more headers in post request , getting 200 status code. try this! not being able send request content wbxml in turn providing meaningless characters in response.
Comments
Post a Comment