public async Task <string> Post(ProductModel entity) { KeyValuePair <string, string>[] requestHeaders = { new KeyValuePair <string, string>("correlationId", "") }; string response = await _apiClient.Post("request", entity, requestHeaders); return(response); }
public async void SubscribeContent(ConfigurationFile configurationFile) { var input = new ContentMetadata { SubscriberId = SubscriberMetadata.SubscriberId, Topics = configurationFile.ContentMetadata.Topics }; var response = await HttpRestClient.Post(Helpers.SubscribeContentUrl(configurationFile.BaseUrl), input); Console.WriteLine(response); }
private async void PublishContent(int nodeNumber) { var input = new ContentMetadata { Message = $"Message from Publisher {nodeNumber},", Topics = ConfigurationFile.ContentMetadata.Topics }; var response = await HttpRestClient.Post(Helpers.PublishTopicUrl(ConfigurationFile.BaseUrl), input); Console.WriteLine(response); }
private void buttonSelectNumber_Click(object sender, EventArgs e) { if (listViewNumbersSearch.SelectedItems != null && listViewNumbersSearch.SelectedItems.Count > 0) { SelectedNumber = listViewNumbersSearch.SelectedItems[0].Text; string url = ApiClient.GetNumberReserveUrl(); HttpRestClient client = new HttpRestClient(); NumberReserveRequest request = ApiClient.BuildNumberResesrveRequest(listViewNumbersSearch.SelectedItems[0].Text, _lastSearchedAreaCode); HttpResponse <List <NumberReserveResponse> > response = client.Post <List <NumberReserveResponse>, NumberReserveRequest>(url, request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { UseWaitCursor = false; if (response.Body != null & response.Body.Count > 0) { foreach (NumberReserveResponse r in response.Body) { listViewNumbersSearch.Items.Add(r.PhoneNumber); } labelValidation.Visible = true; } else { labelValidation.Visible = true; } } else { UseWaitCursor = false; labelValidation.Visible = true; using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(response.ErrorMessage))) { stream.Position = 0; DataContractJsonSerializer serizlizer = new DataContractJsonSerializer(typeof(ErrorResponse)); ErrorResponse errorResponse = serizlizer.ReadObject(stream) as ErrorResponse; labelValidation.Text = errorResponse.Message; } } Close(); } else { labelValidation.Text = "No number selected"; } }
/// <summary> /// Verify the given [ApiKey] for User. /// </summary> /// <param name="apiKey">Your [ApiKey]</param> /// <returns>A boolean value representing if [ApiKey] is correct or not.</returns> public VerifyApiKeyResult VerifyApiKey(string apiKey) { apiKey.CheckReferenceIsNull(nameof(apiKey)); var client = new HttpRestClient <string, bool>(_httpClient, ENDPOINT_VerifyApiKey); client.WithApiKey(apiKey); try { return(VerifyApiKeyResult.Ok(client.Post())); } catch (Exception ex) { return(VerifyApiKeyResult.Failed(ex)); } }
public async void SubscribeFunction(ConfigurationFile configurationFile) { foreach (var function in configurationFile.FunctionsMetadata.Functions) { var input = new FunctionEndpoint { SubscriberId = SubscriberMetadata.SubscriberId, FunctionType = function.FunctionType, SubscriptionTopic = function.SubscriptionTopic, MatchingFunction = function.MatchingFunction, MatchingInputs = function.MatchingInputs }; var response = await HttpRestClient.Post(Helpers.SubscribeFunctionUrl(configurationFile.BaseUrl), input); Console.WriteLine(response); } }
private async void PublishFunctions(int nodeNumber) { foreach (var function in ConfigurationFile.FunctionsMetadata.Functions) { var input = new FunctionEndpoint { Message = $"Message from Publisher {nodeNumber},", FunctionType = function.FunctionType, SubscriptionTopic = function.SubscriptionTopic, MatchingFunction = function.MatchingFunction, MatchingInputs = function.MatchingInputs }; var response = await HttpRestClient.Post(Helpers.PublishFunctionUrl(ConfigurationFile.BaseUrl), input); Console.WriteLine(response); } }
public string MakeAccessTokenRequest(string code) { const string baseUrl = "https://open-ic.epic.com/argonaut/oauth2/token"; var accessTokenRequest = new AccessTokenRequest(); accessTokenRequest.grant_type = "authorization_code"; accessTokenRequest.code = code; accessTokenRequest.redirect_uri = RedirectUrl; accessTokenRequest.client_id = ClinetId; var client = new HttpRestClient(); var response = client.Post <string, AccessTokenRequest>(baseUrl, accessTokenRequest, null, "application/x-www-form-urlencoded"); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(response.Body); } else { return(null); } }
public override async Task <string> ExecuteFunction(object parameters) { return(await HttpRestClient.Post(FunctionAddress, parameters)); }