Giter Club home page Giter Club logo

Comments (8)

therve avatar therve commented on May 27, 2024 1

Fixed in #399

from datadog-api-client-typescript.

therve avatar therve commented on May 27, 2024

Thank you for your report. It sounds like an issue with the backend. In the meantime, your issue is with the dateHappened field, you need to pass a recent timestamp to be able to submit events.

from datadog-api-client-typescript.

kthompson23 avatar kthompson23 commented on May 27, 2024

@therve I can post to the https://api.datadoghq.com/api/v1/events endpoint without issue though.

from datadog-api-client-typescript.

therve avatar therve commented on May 27, 2024

WIth specifying dateHappened: 1, in your payload?

from datadog-api-client-typescript.

therve avatar therve commented on May 27, 2024

FWIW I tried your example and it fails with event too far in the past , the issue is that the error doesn't have the proper content type so it's not parsed properly by the client. But your payload is still invalid, even if we should give a better error.

from datadog-api-client-typescript.

DrPhil avatar DrPhil commented on May 27, 2024

I'm on version 1.0.0-beta.6 of @datadog/datadog-api-client and I'm also receiving the same error: Error: The mediaType text/plain is not supported by ObjectSerializer.parse.. I'm getting it when I'm trying to push metrics. I'm using the typescript example from https://docs.datadoghq.com/api/latest/metrics/#submit-metrics

Node-version: v16.13.0
OS: Manjaro Linux

from datadog-api-client-typescript.

kthompson23 avatar kthompson23 commented on May 27, 2024

@therve Surprisingly yes. The returned event has the current date on it.

const body = {
	aggregationKey: 'aggregationKey_example',
	alertType: 'info',
	dateHappened: 1,
	deviceName: 'deviceName_example',
	host: 'host_example',
	priority: 'normal',
	relatedEventId: 1,
	sourceTypeName: 'sourceTypeName_example',
	tags: ['environment:test'],
	text: 'Oh boy!',
	title: 'Testing event post',
};
const { data } = await axios.post('https://api.datadoghq.com/api/v1/events', body, {
	headers: {
		contentType: 'application/json',
		'DD-API-KEY': process.env.DD_API_KEY,
	},
});

The response:

{
  status: 'ok',
  event: {
    id: 6269305086122181000,
    id_str: '6269305086122180270',
    title: 'Testing event post',
    text: 'Oh boy!',
    date_happened: 1637942568,
    handle: null,
    priority: 'normal',
    related_event_id: null,
    tags: [ 'environment:test' ],
    url: 'https://app.datadoghq.com/event/event?id=6269305086122180270'
  }
}

I understand the issue now though, thank you. In my project I was using Date.now() to set the dateHappened property. I didn't notice that the field is supposed to be seconds since the epoch and Date.now() is milliseconds since the epoch. By passing seconds I was able to post an event. I should have posted my project code.

from datadog-api-client-typescript.

DrPhil avatar DrPhil commented on May 27, 2024

I think the error message could be greatly improved. In my case it was a missing environment variable. One of (DD_SITE="datadoghq.eu" DD_API_KEY="" DD_APP_KEY="") was not set.

from datadog-api-client-typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.