{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-client/issues/250","repository_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-client","labels_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-client/issues/250/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-client/issues/250/comments","events_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-client/issues/250/events","html_url":"https://github.com/Azure/azure-mobile-apps-net-client/issues/250","id":183321633,"number":250,"title":"Offline Sync: PullAsync sends always 2 HTTP Request (one with Skip=0, one with Skip=1)","user":{"login":"ericbrunner","id":6480047,"avatar_url":"https://avatars.githubusercontent.com/u/6480047?v=3","gravatar_id":"","url":"https://api.github.com/users/ericbrunner","html_url":"https://github.com/ericbrunner","followers_url":"https://api.github.com/users/ericbrunner/followers","following_url":"https://api.github.com/users/ericbrunner/following{/other_user}","gists_url":"https://api.github.com/users/ericbrunner/gists{/gist_id}","starred_url":"https://api.github.com/users/ericbrunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericbrunner/subscriptions","organizations_url":"https://api.github.com/users/ericbrunner/orgs","repos_url":"https://api.github.com/users/ericbrunner/repos","events_url":"https://api.github.com/users/ericbrunner/events{/privacy}","received_events_url":"https://api.github.com/users/ericbrunner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-17T04:11:17Z","updated_at":"2016-10-18T17:06:39Z","closed_at":null,"body":"Hi,\r\n\r\nI recently noticed that a simply PullAsync always sends 2 requests to my backend and I really don't know why. \r\n\r\n**My code:**\r\n\r\n` await OfflineSyncStoreManager.Instance.TruckAuftragTable.PullAsync(\"allTruckAuftragItems\",\r\n                    OfflineSyncStoreManager.Instance.TruckAuftragTable.CreateQuery());`\r\n\r\n**My result:** \r\nI log it at the very begin of my DelegatingHandler's SendAsync method:\r\n\r\n`Debug.WriteLine(\"Request: {0} {1} {2}\", DateTime.Now, request.Method, request.RequestUri.ToString());\r\n`\r\n\r\n**Logmessages:**\r\n\r\nLine 1455: [0:] Request: 10/17/2016 04:02:19 GET https://trucker-rolsped.azurewebsites.net/tables/TruckAuftrag?$filter=(updatedAt ge datetimeoffset'2016-10-16T21:56:41.1730000%2B00:00')&$orderby=updatedAt&$**skip=0**&$top=50&__includeDeleted=true\r\n\t\r\nLine 1514: [0:] Request: 10/17/2016 04:02:20 GET https://trucker-rolsped.azurewebsites.net/tables/TruckAuftrag?$filter=(updatedAt ge datetimeoffset'2016-10-16T21:56:41.1730000%2B00:00')&$orderby=updatedAt&$**skip=1**&$top=50&__includeDeleted=true\r\n\r\nthanks for an help,\r\nEric"},"comment":{"url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-client/issues/comments/254573711","html_url":"https://github.com/Azure/azure-mobile-apps-net-client/issues/250#issuecomment-254573711","issue_url":"https://api.github.com/repos/Azure/azure-mobile-apps-net-client/issues/250","id":254573711,"user":{"login":"ericbrunner","id":6480047,"avatar_url":"https://avatars.githubusercontent.com/u/6480047?v=3","gravatar_id":"","url":"https://api.github.com/users/ericbrunner","html_url":"https://github.com/ericbrunner","followers_url":"https://api.github.com/users/ericbrunner/followers","following_url":"https://api.github.com/users/ericbrunner/following{/other_user}","gists_url":"https://api.github.com/users/ericbrunner/gists{/gist_id}","starred_url":"https://api.github.com/users/ericbrunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericbrunner/subscriptions","organizations_url":"https://api.github.com/users/ericbrunner/orgs","repos_url":"https://api.github.com/users/ericbrunner/repos","events_url":"https://api.github.com/users/ericbrunner/events{/privacy}","received_events_url":"https://api.github.com/users/ericbrunner/received_events","type":"User","site_admin":false},"created_at":"2016-10-18T17:06:39Z","updated_at":"2016-10-18T17:06:39Z","body":"@adrianhall I will try. But my code blocks on the DebugLog of the response. Can you tell my why?\r\n\r\n`    class AuthenticationDelegatingHandler : DelegatingHandler\r\n    {\r\n        private readonly bool _logRequestResponseBody;\r\n\r\n\r\n        public AuthenticationDelegatingHandler(bool logRequestResponseBody = false)\r\n        {\r\n            this._logRequestResponseBody = logRequestResponseBody;\r\n        }\r\n\r\n        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,\r\n            CancellationToken cancellationToken)\r\n        {\r\n            Debug.WriteLine(\"Request: {0} {1} {2}\", DateTime.Now, request.Method, request.RequestUri.ToString());\r\n            HttpResponseMessage response = null;\r\n\r\n            try\r\n            {\r\n                //await DebugLogRequest(request).ConfigureAwait(false);\r\n\r\n                // Clone the request, in case we need to re-issue it\r\n                var clone = await CloneHttpRequestMessageAsync(request).ConfigureAwait(false);\r\n\r\n                // Now do the request\r\n                response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);\r\n\r\n                if (response.StatusCode == HttpStatusCode.Unauthorized)\r\n                {\r\n                    // The request resulted in a 401 Unauthorized.  We need to do a LoginAsync,\r\n                    // which will do the Refresh if appropriate, or ask for credentials if not.\r\n                    App.TruckDriver = await DependencyService.Get<IAuthenticate>().SignIn().ConfigureAwait(false);\r\n\r\n                    // Now, retry the request with the cloned request.  The only thing we have\r\n                    // to do is replace the X-ZUMO-AUTH header with the new auth token.\r\n                    clone.Headers.Remove(\"X-ZUMO-AUTH\");\r\n                    clone.Headers.Add(\"X-ZUMO-AUTH\", App.TruckDriver.MobileUserInfo.MobileServiceAuthenticationToken);\r\n                    response = await base.SendAsync(clone, cancellationToken).ConfigureAwait(false);\r\n                }\r\n\r\n                await DebugLogResponse(response).ConfigureAwait(false);\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                Debug.WriteLine(e.Message);\r\n                Debugger.Break();\r\n            }\r\n\r\n            return response;\r\n        }\r\n\r\n        private async Task DebugLogRequest(HttpRequestMessage request)\r\n        {\r\n            try\r\n            {\r\n                if (_logRequestResponseBody && request.Content != null)\r\n                {\r\n                    var requestContent = await request.Content.ReadAsStringAsync().ConfigureAwait(false);\r\n                    Debug.WriteLine($\"{DateTime.Now} - REQUEST: {requestContent}\");\r\n                }\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                Debug.WriteLine(e.Message);\r\n                Debugger.Break();\r\n            }\r\n\r\n        }\r\n\r\n        private async Task DebugLogResponse(HttpResponseMessage response)\r\n        {\r\n            try\r\n            {\r\n                Debug.WriteLine(\"Response: {0}\", response.StatusCode);\r\n\r\n                if (_logRequestResponseBody)\r\n                {\r\n                    var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);\r\n                    Debug.WriteLine($\"{DateTime.Now} - RESPONSE: {responseContent}\");\r\n                }\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                Debug.WriteLine(e.Message);\r\n                Debugger.Break();\r\n            }\r\n\r\n        }`"}}
{"actor":{"display_login":"ericbrunner"}}