Type Error when submitting logs
niallmc opened this issue · comments
Describe the bug
When trying to submit a log I receive a type error
To Reproduce
Follow the example from the docs.
import { v1 } from "@datadog/datadog-api-client";
const configuration = v1.createConfiguration();
const apiInstance = new v1.LogsApi(configuration);
let params: v1.LogsApiSubmitLogRequest = {
// Array<HTTPLogItem> | Log to send (JSON format).
body: [
{
ddsource: "nginx",
ddtags: "env:staging,version:5.1",
hostname: "i-012345678",
message:
"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
service: "payment",
},
{
ddsource: "nginx",
ddtags: "env:staging,version:5.1",
hostname: "i-012345678",
message:
"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
service: "payment",
},
],
// ContentEncoding | HTTP header used to compress the media-type. (optional)
contentEncoding: "gzip",
// string | Log tags can be passed as query parameters with `text/plain` content type. (optional)
ddtags: "env:prod,user:my-user",
};
apiInstance
.submitLog(params)
.then((data: any) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
I receive the following type error when the code is called.
TypeError: missing required attribute 'code' on 'HTTPLogError' object
Expected behavior
I expect the example code should run without an error, or the docs need to be updated to show a working example.
Environment and Versions (please complete the following information):
- @datadog/datadog-api-client 1.0.0-beta.5
- nodejs v14.15.1
Quick follow up:
I just checked in the other client libraries and found the same issue reported in the go client: DataDog/datadog-api-client-go#1135
Following the described changes of disabling content-encoding, the request then works.
It appears the gzip content-encoding is causing issues.
Hi, it should be fixed by #291 . Thanks.