Influxdb task failed to work

Hi, I’d like have a task which check one value, if it is more than defined value, then send a post request to remove data.
But when i use the following task, it does not seem to work, can some one help me take a look?

PS, i already tested post request in curl separately, it works.
Thanks.


import “http”

option task = {name: “testtask”, every: 1h}

from(bucket: “systembucket”)

|> range(start: -task.every)

|> filter(fn: (r) =>  (r._measurement == "du2"))
|> filter(fn: (r) =>  (r._value > 10000))

|> aggregateWindow(every: 24h, fn: mean, createEmpty: false)

|> limit(n: 1, offset: 0)

|> map(fn: (r) =>

    ({r with status_code: http.post(url: "http://localhost:8086/api/v2/delete?org=testorg&bucket=testbucket", headers: {"Content-Type": "application/json", Authorization: "Token faketoken"}, data: bytes(v: "{\"start\": 2021-01-11T22:00:00Z, \"stop\": 2021-01-12T00:00:00Z}"))}))

Hello @sophia ,
I think the timestamps need to be in string like bytes(v: "{\"start\": \"2021-01-11T22:00:00Z\", \"stop\": \"2021-01-12T00:00:00Z\"}")

Does that work?