Skip to content

Commit ef61afc

Browse files
committed
fix(write-api): Serverless write 201 response codes
Helps https://github.com/influxdata/idpe/issues/18710 InfluxDB v3 Serverless will soon return 201 or 204, in cases where it currently returns 204.
1 parent 07f1f5e commit ef61afc

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

api-docs/cloud-serverless/v2/ref.yml

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ tags:
262262
|  Code  | Status | Description |
263263
|:-----------:|:------------------------ |:--------------------- |
264264
| `200` | Success | |
265-
| `201` | Created | Successfully created a resource. The response body may contain details. |
266-
| `204` | No content | The request succeeded. InfluxDB doesn't typically return a response body for the operation. The [`/write`](#operation/PostLegacyWrite) and [`/api/v2/write`](#operation/PostWrite) endpoints return a response body if some points are written and some are rejected. |
265+
| `201` | Created | Successfully created a resource. The response body may contain details, for example [`/write`](#operation/PostLegacyWrite) and [`/api/v2/write`](#operation/PostWrite) response bodies contain details of partial write failures. |
266+
| `204` | No content | The request succeeded. |
267267
| `400` | Bad request | InfluxDB can't parse the request due to an incorrect parameter or bad syntax. For _writes_, the error may indicate one of the following problems: <ul><li>Line protocol is malformed. The response body contains the first malformed line in the data and indicates what was expected.</li><li>The batch contains a point with the same series as other points, but one of the field values has a different data type.<li>`Authorization` header is missing or malformed or the API token doesn't have permission for the operation.</li></ul> |
268268
| `401` | Unauthorized | May indicate one of the following: <ul><li>`Authorization: Token` header is missing or malformed</li><li>API token value is missing from the header</li><li>API token doesn't have permission. For more information about token types and permissions, see [Manage API tokens](/influxdb/cloud-serverless/security/tokens/)</li></ul> |
269269
| `404` | Not found | Requested resource was not found. `message` in the response body provides details about the requested resource. |
@@ -7487,14 +7487,17 @@ paths:
74877487
74887488
InfluxDB Cloud Serverless does the following when you send a write request:
74897489
7490-
1. Validates the request.
7491-
2. If successful, attempts to [ingest the data](/influxdb/cloud-serverless/reference/internals/durability/#data-ingest); [error](/influxdb/cloud-serverless/write-data/troubleshoot/#review-http-status-codes) otherwise.
7492-
3. If some or all points in the batch are written, responds with an HTTP `204 "No Content"` status code, acknowledging that data is written and queryable; error otherwise.
7490+
1. Validates the request.
7491+
2. If successful, attempts to [ingest data](/influxdb/cloud-serverless/reference/internals/durability/#data-ingest) from the request body; otherwise, responds with an [error status](/influxdb/cloud-serverless/write-data/troubleshoot/#review-http-status-codes).
7492+
3. Ingests or rejects data in the batch and returns one of the following HTTP status codes:
74937493
7494-
- `204 "No Content"`: Data in the batch is written and queryable.
7495-
- `400 "Bad Request"`: The entire batch is rejected.
7494+
- `204 No Content`: all data in the batch is ingested
7495+
- `201 Created`: some points in the batch are ingested and queryable, and some points are rejected
7496+
- `400 Bad Request`: all data is rejected
74967497
7497-
If some points in the batch are rejected, the response body contains details about the [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points).
7498+
The response body contains error details about [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points), up to 100 points.
7499+
7500+
Writes are synchronous--the response status indicates the final status of the write and all ingested data is queryable.
74987501
74997502
To ensure that InfluxDB handles writes in the order you request them,
75007503
wait for the response before you send the next request.
@@ -7636,12 +7639,9 @@ paths:
76367639
- [Best practices for optimizing writes](/influxdb/cloud-serverless/write-data/best-practices/optimize-writes/)
76377640
required: true
76387641
responses:
7639-
'204':
7642+
'201':
76407643
description: |
7641-
Success.
7642-
Data in the batch is written and queryable.
7643-
7644-
If some points in the batch are rejected, the response body contains details about the [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points), up to 100 points.
7644+
Success ("Created"). Some points in the batch are written and queryable, and some points are rejected. The response body contains details about the [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points), up to 100 points.
76457645
content:
76467646
application/json:
76477647
examples:
@@ -7653,6 +7653,8 @@ paths:
76537653
message: 'failed to parse line protocol: errors encountered on line(s): error message for first rejected point</n> error message for second rejected point</n> error message for Nth rejected point (up to 100 rejected points)'
76547654
schema:
76557655
$ref: '#/components/schemas/LineProtocolError'
7656+
'204':
7657+
description: Success ("No Content"). All data in the batch is written and queryable.
76567658
'400':
76577659
description: |
76587660
All data in the batch was rejected and not written.
@@ -7916,18 +7918,21 @@ paths:
79167918
description: |
79177919
Writes data to a bucket.
79187920
7919-
Use this endpoint to send data in [line protocol](/influxdb/cloud-serverless/reference/syntax/line-protocol/) format to InfluxDB.
7921+
Use this endpoint for [InfluxDB v1 parameter compatibility](/influxdb/cloud-serverless/guides/api-compatibility/v1/) when sending data in [line protocol](/influxdb/cloud-serverless/reference/syntax/line-protocol/) format to InfluxDB.
79207922
79217923
InfluxDB Cloud Serverless does the following when you send a write request:
79227924
7923-
1. Validates the request.
7924-
2. If successful, attempts to [ingest the data](/influxdb/cloud-serverless/reference/internals/durability/#data-ingest); [error](/influxdb/cloud-serverless/write-data/troubleshoot/#review-http-status-codes) otherwise.
7925-
3. If some or all points in the batch are written, responds with an HTTP `204 "No Content"` status code, acknowledging that data is written and queryable; error otherwise.
7925+
1. Validates the request.
7926+
2. If successful, attempts to [ingest data](/influxdb/cloud-serverless/reference/internals/durability/#data-ingest) from the request body; otherwise, responds with an [error status](/influxdb/cloud-serverless/write-data/troubleshoot/#review-http-status-codes).
7927+
3. Ingests or rejects data in the batch and returns one of the following HTTP status codes:
79267928
7927-
- `204 "No Content"`: Data in the batch is written and queryable.
7928-
- `400 "Bad Request"`: The entire batch is rejected.
7929+
- `204 No Content`: all data in the batch is ingested
7930+
- `201 Created`: some points in the batch are ingested and queryable, and some points are rejected
7931+
- `400 Bad Request`: all data is rejected
79297932
7930-
If some points in the batch are rejected, the response body contains details about the [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points).
7933+
The response body contains error details about [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points), up to 100 points.
7934+
7935+
Writes are synchronous--the response status indicates the final status of the write and all ingested data is queryable.
79317936
79327937
To ensure that InfluxDB handles writes in the order you request them,
79337938
wait for the response before you send the next request.
@@ -7995,12 +8000,9 @@ paths:
79958000
description: Line protocol body
79968001
required: true
79978002
responses:
7998-
'204':
8003+
'201':
79998004
description: |
8000-
Success.
8001-
Data in the batch is written and queryable.
8002-
8003-
If some points in the batch are rejected, the response body contains details about the [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points), up to 100 points.
8005+
Success ("Created"). Some points in the batch are written and queryable, and some points are rejected. The response body contains details about the [rejected points](/influxdb/cloud-serverless/write-data/troubleshoot/#troubleshoot-rejected-points), up to 100 points.
80048006
content:
80058007
application/json:
80068008
examples:
@@ -8012,6 +8014,8 @@ paths:
80128014
message: 'failed to parse line protocol: errors encountered on line(s): error message for first rejected point</n> error message for second rejected point</n> error message for Nth rejected point (up to 100 rejected points)'
80138015
schema:
80148016
$ref: '#/components/schemas/LineProtocolError'
8017+
'204':
8018+
description: Success ("No Content"). All data in the batch is written and queryable.
80158019
'400':
80168020
description: |
80178021
All data in the batch is rejected and not written.

content/influxdb/cloud-serverless/write-data/troubleshoot.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ The `message` property of the response body may contain additional details about
5151

5252
| HTTP response code | Response body | Description |
5353
| :-------------------------------| :--------------------------------------------------------------- | :------------- |
54-
| `204 "No Content"` | error details about rejected points, up to 100 points: `line` contains the first rejected line, `message` describes rejected points | If InfluxDB ingested some or all of the data |
54+
| `201 "Created"` | error details about rejected points, up to 100 points, `line` contains the first rejected line, `message` describes rejections | If some of the data is ingested and some of the data is rejected |
55+
| `204 "No Content"` | no response body | If InfluxDB ingested all of the data in the batch |
5556
| `400 "Bad request"` | `line` contains the first malformed line, `message` describes rejected points | If request data is malformed |
5657
| `401 "Unauthorized"` | | If the `Authorization` header is missing or malformed or if the [token](/influxdb/cloud-serverless/admin/tokens/) doesn't have [permission](/influxdb/cloud-serverless/admin/tokens/create-token/) to write to the bucket. See [examples using credentials](/influxdb/cloud-serverless/get-started/write/#write-line-protocol-to-influxdb) in write requests. |
5758
| `403 "Forbidden"` | `message` contains details about the error | If the data isn't allowed (for example, falls outside of the bucket's retention period).

0 commit comments

Comments
 (0)