var url = this.haproxy.Client.BaseUrl + this.haproxy.BaseUrl + this.baseUrl + "/addAcl"; var acl = new { acl = new { name = name, expression = "hdr_sub", hdr_sub = name, negate = "0" } }; var serializerSettings = new JsonSerializerSettings(); serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); var json = JsonConvert.SerializeObject(acl, serializerSettings); var response = await this.haproxy.Client.httpClient.PostAsJsonAsync(url, json, cancellationToken);
{"acl":{"name":"NewACL","description":"API Check","expression":"hdr","negate":"0","caseSensitive":"0","hdr_beg":"","hdr_end":"","hdr":"opnsense.org","hdr_reg":"","hdr_sub":"","path_beg":"","path_end":"","path":"","path_reg":"","path_dir":"","path_sub":"","cust_hdr_beg_name":"","cust_hdr_beg":"","cust_hdr_end_name":"","cust_hdr_end":"","cust_hdr_name":"","cust_hdr":"","cust_hdr_reg_name":"","cust_hdr_reg":"","cust_hdr_sub_name":"","cust_hdr_sub":"","url_param":"","url_param_value":"","ssl_c_verify_code":"","ssl_c_ca_commonname":"","src":"","src_bytes_in_rate_comparison":"gt","src_bytes_in_rate":"","src_bytes_out_rate_comparison":"gt","src_bytes_out_rate":"","src_conn_cnt_comparison":"gt","src_conn_cnt":"","src_conn_cur_comparison":"gt","src_conn_cur":"","src_conn_rate_comparison":"gt","src_conn_rate":"","src_http_err_cnt_comparison":"gt","src_http_err_cnt":"","src_http_err_rate_comparison":"gt","src_http_err_rate":"","src_http_req_cnt_comparison":"gt","src_http_req_cnt":"","src_http_req_rate_comparison":"gt","src_http_req_rate":"","src_kbytes_in_comparison":"gt","src_kbytes_in":"","src_kbytes_out_comparison":"gt","src_kbytes_out":"","src_port_comparison":"gt","src_port":"","src_sess_cnt_comparison":"gt","src_sess_cnt":"","nbsrv":"","nbsrv_backend":"","ssl_fc_sni":"","ssl_sni":"","ssl_sni_sub":"","ssl_sni_beg":"","ssl_sni_end":"","ssl_sni_reg":"","allowedUsers":"","allowedGroups":"","custom_acl":""}}
{"acl":{"name":"test","description":"","expression":"hdr","negate":"0","caseSensitive":"0","hdr_beg":"","hdr_end":"","hdr":"test.test.com","hdr_reg":"","hdr_sub":"","path_beg":"","path_end":"","path":"","path_reg":"","path_dir":"","path_sub":"","cust_hdr_beg_name":"","cust_hdr_beg":"","cust_hdr_end_name":"","cust_hdr_end":"","cust_hdr_name":"","cust_hdr":"","cust_hdr_reg_name":"","cust_hdr_reg":"","cust_hdr_sub_name":"","cust_hdr_sub":"","url_param":"","url_param_value":"","ssl_c_verify_code":"","ssl_c_ca_commonname":"","src":"","src_bytes_in_rate_comparison":"gt","src_bytes_in_rate":"","src_bytes_out_rate_comparison":"gt","src_bytes_out_rate":"","src_conn_cnt_comparison":"gt","src_conn_cnt":"","src_conn_cur_comparison":"gt","src_conn_cur":"","src_conn_rate_comparison":"gt","src_conn_rate":"","src_http_err_cnt_comparison":"gt","src_http_err_cnt":"","src_http_err_rate_comparison":"gt","src_http_err_rate":"","src_http_req_cnt_comparison":"gt","src_http_req_cnt":"","src_http_req_rate_comparison":"gt","src_http_req_rate":"","src_kbytes_in_comparison":"gt","src_kbytes_in":"","src_kbytes_out_comparison":"gt","src_kbytes_out":"","src_port_comparison":"gt","src_port":"","src_sess_cnt_comparison":"gt","src_sess_cnt":"","nbsrv":"","nbsrv_backend":"","ssl_fc_sni":"","ssl_sni":"","ssl_sni_sub":"","ssl_sni_beg":"","ssl_sni_end":"","ssl_sni_reg":"","allowedUsers":"","allowedGroups":"","custom_acl":""}}
{"result":"failed"}
var response = await this.haproxy.Client.httpClient.PostAsJsonAsync(url, json, cancellationToken);
You have been able to insert new ACL by this way ?
var url = this.haproxy.Client.BaseUrl + this.haproxy.BaseUrl + this.baseUrl + "/addAcl"; var model = new { acl = new { negate = "0", name = name, expression = "hdr_end" } }; var response = await this.haproxy.Client.httpClient.PostAsync(url, JsonContent.Create(model));