1
22.7 Legacy Series / Using API on api/haproxy/settings/addAcl ==> "result": "failed"
« on: August 16, 2022, 02:10:50 am »
Hello,
I work a day to find a way to POST a new ACL via the API of HAProxy.
Can anyone can help me to know the exact format of JSON I have to create ?
I am using C#. There is my code :
I tried a lot of format, but I always got "result": "failed" from OpnSense.
Thank you for your help !
I work a day to find a way to POST a new ACL via the API of HAProxy.
Can anyone can help me to know the exact format of JSON I have to create ?
I am using C#. There is my code :
Code: [Select]
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);
I tried a lot of format, but I always got "result": "failed" from OpnSense.
Thank you for your help !