Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Bad Request - type is a required field #3066

Closed
zbycz opened this issue Nov 25, 2024 · 3 comments
Closed

400 Bad Request - type is a required field #3066

zbycz opened this issue Nov 25, 2024 · 3 comments

Comments

@zbycz
Copy link

zbycz commented Nov 25, 2024

Describe the Bug

Hi,

i wonder what might be the reason for this error message.

$ [Error]: 400 Bad Request at https://cloud.umami.is/api/send
    at d (/var/task/.next/server/chunks/2595.js:71:2253)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async m (/var/task/.next/server/chunks/2595.js:71:2337) {
  code: '400',
  data: 'type is a required field'
}

I am sending the following headers and payload. When I compare it with other successful requests, the only difference is missing brackets in the user-agent header. Could it be the issue? The message "type is required" doesn't indicate this..

My failing request:

const data= {
    "type": "event",
    "payload": {
      "name": "next-server",
      "website": "5e4d4917-9031-42f1-a26a-e71d7ab8e3fe",
      "url": "/",
      "hostname": "osmapp-r3cgr65bz-osm-app-team.vercel.app",
      "language": "en"
    }
}

const headers = {
    "X-Client-IP": "128.199.0.145",
    "User-Agent": "vercel-screenshot/1.0"
}

fetch('https://cloud.umami.is/api/send', {
    method: 'POST',
    headers,
    body: JSON.stringify(data),
  })

Database

Umami Cloud

@mikecao
Copy link
Collaborator

mikecao commented Nov 25, 2024

Is that the actual request you're sending? It should juse be:

{
  "type": "event",
  "payload": { }
}

@zbycz
Copy link
Author

zbycz commented Nov 28, 2024

No, it was only for debugging. I updated the description of the issue. I am still getting the 400 with strange description "type is required" even though i send the field correctly.

I am executing the code with this call in node.js

fetch('https://cloud.umami.is/api/send', {
    method: 'POST',
    headers,
    body: JSON.stringify(data),
  })

@zbycz
Copy link
Author

zbycz commented Nov 28, 2024

I've got it! I was missing the content-type header. So the description was only a bit misleading.. I suggest changing the error to Content-Type is a required field.

@zbycz zbycz closed this as completed Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants