public IEnumerator <ITask> GetSlot(string @namespace, string userId, string accessToken, string slotId, ResultCallback <byte[]> callback) { Assert.IsNotNull(@namespace, "Can't get the slot! namespace parameter is null!"); Assert.IsNotNull(userId, "Can't get the slot! userId parameter is null!"); Assert.IsNotNull(accessToken, "Can't get the slot! accessToken parameter is null!"); Assert.IsNotNull(slotId, "Can't get the slot! slotId parameter is null!"); var request = HttpRequestBuilder .CreateGet(this.baseUrl + "/binary-store/namespaces/{namespace}/users/{userId}/slots/{slotId}") .WithPathParam("namespace", @namespace) .WithPathParam("userId", userId) .WithPathParam("slotId", slotId) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .ToRequest(); HttpWebResponse response = null; yield return(Task.Await(request, rsp => response = rsp)); if (response == null) { callback.Try(Result <byte[]> .CreateError(ErrorCode.NetworkError, "There is no response")); yield break; } //TODO: Might need to transfer data via stream for big files var responseBytes = response.GetBodyRaw(); response.Close(); Result <byte[]> result; switch (response.StatusCode) { case HttpStatusCode.OK: result = Result <byte[]> .CreateOk(responseBytes); break; default: result = Result <byte[]> .CreateError((ErrorCode)response.StatusCode); break; } callback.Try(result); }