Documentation

requests.post() 函数

requests.post() 发起一个 http POST 请求。这与调用 request.do(method: "POST", ...) 是相同的。

函数类型签名
(
    url: string,
    ?body: bytes,
    ?config: {A with timeout: duration, insecureSkipVerify: bool},
    ?headers: [string:string],
    ?params: [string:[string]],
) => {statusCode: int, headers: [string:string], duration: duration, body: bytes}

有关更多信息,请参见 Function type signatures

参数

网址

(必填) 请求的URL。这里不应该包括任何查询参数。

参数

要添加到URL作为查询参数的一组键值对。 查询参数将被URL编码。 与一个键相关的所有值将附加到查询中。

头部信息

请求中要包含的键值对集合。

主体

要随请求发送的数据。

配置

控制请求执行方式的选项集。

示例

使用 JSON 主体进行 POST 请求并解码 JSON 响应

import "http/requests"
import ejson "experimental/json"
import "json"
import "array"

response =
    requests.post(
        url: "https://goolnk.com/api/v1/shorten",
        body: json.encode(v: {url: "http://www.influxdata.com"}),
        headers: ["Content-Type": "application/json"],
    )

data = ejson.parse(data: response.body)

array.from(rows: [data])

查看示例输出

使用查询参数进行POST请求

import "http/requests"

response =
    requests.post(url: "http://example.com", params: ["start": ["100"], "interval": ["1h", "1d"]])

// Full URL: http://example.com?start=100&interval=1h&interval=1d
requests.peek(response: response)

查看示例输出



Flux的未来

Flux 正在进入维护模式。您可以像现在一样继续使用它,而无需对您的代码进行任何更改。

阅读更多

InfluxDB 3 开源版本现已公开Alpha测试

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

我们将发布两个产品作为测试版的一部分。

InfluxDB 3 核心,是我们新的开源产品。 它是一个用于时间序列和事件数据的实时数据引擎。 InfluxDB 3 企业版是建立在核心基础之上的商业版本,增加了历史查询能力、读取副本、高可用性、可扩展性和细粒度安全性。

有关如何开始的更多信息,请查看: