API POST Tranport variables

I have created an API transport to send the alerts to another application - Spectrum.
I can create the alarm using curl with the following syntax:
curl --user user:pass --header "Content-Type:application/json" --header "Accept:application/json" --request POST "http://host:8080/spectrum/restful/events/0xfff000fa/model/0x1100ac8c?varbind=1&val=alarmtest1&varbind=2&val=alarmmsg2"
How can I get this same config in Libre’s Transport settings? This is what I have now:


However, the variables arrive empty in Spectrum. This is the tcpdump from the spectrum host:

>  dlibrehost.49224 > host.webcache: Flags [P.], cksum 0x43f9 (correct), seq 1:263, ack 1, win 229, length 262: HTTP, length: 262
>         POST /spectrum/restful/events/0xfff000fa/model/0x1100ac8c HTTP/1.1
>         User-Agent: GuzzleHttp/7
>         Authorization: Basic cmVzdHVzZXI6cmVzdHVzZXI=
>         Host: host:8080
>         Content-Type: application/json
>         Accept: application/json
>         Content-Length: 19
> 
>         varbind=1&val=test1[!http]
> 14:47:00.354598 IP (tos 0x0, ttl 64, id 24769, offset 0, flags [DF], proto TCP (6), length 40)

How can I configure the variables correctly?

Fixed by editing the Api.php file. Works only for the variables defined in the Options field.

    } else { //Method POST
        $request_opts['query'] = $query;
        foreach ($query as $metric => $value) { // replace all variables defined in Options and found in Body for their values
            $body = str_replace( '$' . $metric, "$value" , $body);
        }
        $request_opts['body'] = $body;
        $res = $client->request('POST', $host, $request_opts);
    }
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.