private void CallService(string packageId, string packageVersion, string serviceMethod) { string serviceRoot = _orchardServices.WorkContext.CurrentSite.As<GallerySettingsPart>().ServiceRoot; using (var client = new HttpClient(serviceRoot)) { string accessKey = _userkeyService.GetAccessKeyForUser(_authenticationService.GetAuthenticatedUser().Id).AccessKey.ToString(); string uri = string.Format("{0}/{1}", ServiceConstants.PublishedPackageServiceName, serviceMethod); var postData = new { key = accessKey, id = packageId, version = packageVersion }; using (HttpResponseMessage response = client.PostJson(uri, postData)) { if (response.StatusCode != HttpStatusCode.OK) { throw new Exception(response.ReadContentAsStringWithoutQuotes()); } } } }