Flux, Influxdb, HTTP post

Pushsafer make it easy and safe to get push-notifications in real time on your Android or Windows mobile device, iPhone, iPad and Desktop!

Mit Pushsafer kann man in Echtzeit, einfach und sicher, Push-Benachrichtigungen auf sein iPhone, iPad, Android oder Windows Gerät sowie auf den Desktop senden lassen!

======================
Google Play
App Store
Windows Store
Homepage
salvq123

Flux, Influxdb, HTTP post

Postby salvq123 » 26. Jan 2020, 17:00

Hello,

I am using flux scripting lang used by Influxdb database and trying to use HTTP POST to send a message, details https://v2.docs.influxdata.com/v2.0/ref ... http/post/.

Can you let me know how to specify the HTTP request to send a message ?

Thanks

Function

Code: Select all

http.post(
  url: "http://localhost:9999/",
  headers: {x:"a", y:"b", z:"c"},
  data: bytes(v: "body")
)

Example

Code: Select all

import "json"
import "http"

lastReported =
  from(bucket: "example-bucket")
    |> range(start: -1m)
    |> filter(fn: (r) => r._measurement == "statuses")
    |> last()
    |> tableFind(fn: (key) => exists key._level)
    |> getColumn(column: "_level")

http.post(
  url: "http://myawsomeurl.com/api/notify",
  headers: {Authorization: "Bearer mySuPerSecRetTokEn"},
  data: bytes(v: lastReported[0])
)

User avatar
admin
Site Admin
Posts: 943
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: Flux, Influxdb, HTTP post

Postby admin » 26. Jan 2020, 21:23

Hello,

i think this is what you need:

Code: Select all

import "http"

http.post(
  url: "https://www.pushsafer.com/api",
  data: bytes(k: "PRIVATEKEY", d: "DEVICEID", s: "5", i: "12", v: "3")
)

Replace data by you own. You can add more pushsafer parameter in the same way!

Kevin
Pushsafer DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
Pushsafer EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

salvq123

Re: Flux, Influxdb, HTTP post

Postby salvq123 » 30. Jan 2020, 12:53

Unfortunately it does not work.

I have asked influxdb to help to translate HTTP POST from your examples to Flux HTTP POST.

When I get answer, will post solution here.

User avatar
admin
Site Admin
Posts: 943
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: Flux, Influxdb, HTTP post

Postby admin » 30. Jan 2020, 13:13

thanks, i will wait ...
Pushsafer DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
Pushsafer EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10


Who is online

Users browsing this forum: No registered users and 23 guests