# Newbie: Request for example task: get last measurements, process values, http post

**URL:** <https://community.influxdata.com/t/newbie-request-for-example-task-get-last-measurements-process-values-http-post/19282>\
**Category:** Welcome & Getting Started\
**Tags:** influxdb, query, tasks\
**Created:** [April 7, 2021, 5:54pm UTC](https://community.influxdata.com/t/newbie-request-for-example-task-get-last-measurements-process-values-http-post/19282 "2021-04-07T17:54:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cj0](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/cj0/32/7145_2.png) [@cj0](https://community.influxdata.com/u/cj0)\
**Post date:** [April 7, 2021, 5:54pm UTC](https://community.influxdata.com/t/newbie-request-for-example-task-get-last-measurements-process-values-http-post/19282/1 "2021-04-07T17:54:35Z")

</div>

Wishing to post **smart electricity meter** (P1 from EN-IEC 62056-21, Part 21) measurements stored every second in InfluxDB 2.0.4 to the [pvoutput.org](http://pvoutput.org) " Add Status Service" API, I was searching for some Influxdb task creation examples.

Docs has a json example. Over here, a search with keywords “task import http” gives 15 results, though none of the topics provide me help.

Selecting the last measurement data is already challenging. Using “Data Explorer” query:

```
from(bucket: "dsm")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["equipment_id_electricity"] == "39")
  |> filter(fn: (r) => r["_field"] == "mr_byclient_t1" or r["_field"] == "mr_byclient_t2" or r["_field"] == "mr_toclient_t1" or r["_field"] == "mr_toclient_t2")
  |> last(column: "_time")

```

I can get 4 resulting lines just below the “Filter tables…” input. On the right side the table gives the correct value in column “\_value”. With 2 individual queries and some grouping, lasting and summing, I get something similar though not exactly what I wish.

I’d wish to sum the values mr\_toclient\_t1 of mr\_toclient\_t2 as “ **v3** ”. For example the sum I can get in column \_value with this query:

```
from(bucket: "dsm")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["equipment_id_electricity"] == "39")
  |> filter(fn: (r) => r["_field"] == "mr_toclient_t1" or r["_field"] == "mr_toclient_t2")
  |> last(column: "_value")
  |> group(columns: ["_time"], mode:"by")
  |> sum(column: "_value")

```

And add mr\_byclient\_t1 to mr\_byclient\_t2 as “v1”, using query:

```
from(bucket: "dsm")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["equipment_id_electricity"] == "39")
  |> filter(fn: (r) => r["_field"] == "mr_byclient_t1" or r["_field"] == "mr_byclient_t2")
  |> last(column: "_value")
  |> group(columns: ["_time"], mode:"by")
  |> sum(column: "_value")

```

Then I wish to post split the value of column “\_time” to a date (f.e. 20210228) and to a time (f.e. 14:08).

I’d wish to post the highest out of any of the 3 phase voltages. I managed to build that query:

```
from(bucket: "dsm")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["equipment_id_electricity"] == "39")
  |> filter(fn: (r) => r["_field"] == "inst_volt_l1" or r["_field"] == "inst_volt_l2" or r["_field"] == "inst_volt_l3")
  |> max(column: "_value")
  |> group(columns: ["_start"], mode:"by")
  |> max(column: "_value")

```

Additionally I need variable c1=1.

Those 6 ( **d** ate, **t** ime, v1, v3, v6, c1) variables and its values should be sent to [https://pvoutput.org/service/r2/addstatus.jsp](https://pvoutput.org/service/r2/addstatus.jsp) using a **post** or **get** request.

Any help how to accomplish this task, especially extracting and transforming the individual values to corresponding http key value pairs, will be appreciated.

The http.post request should look something like:

```
http.post(
  url: "https://pvoutput.org/service/r2/addstatus.jsp",
  headers: {"X-Pvoutput-Apikey":"321", "X-Pvoutput-SystemId":"123", "content-type":"application/x-www-form-urlencoded"},
  data: bytes(v: "d=........&t=..:..&v1=...&v3=...&v6=...&c1=1")
)

```

In other words: how to build/fill in the **http.post ( data: bytes(v:** part?
