FAQ: How do I troubleshoot 400 errors?

You’ll commonly encounter 400 Bad Request errors when working with APIs. This FAQ tells you what they are and how to fix them.

What does a 400 Bad Request error mean?

The Mozilla developer docs say:

The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

In simpler terms, this normally means that:

  1. The request is missing something that you should have sent. For example, if you’re making an API request that expects an email field to be sent, and you don’t send it, the API may return a 400.
  2. The data you sent isn’t in the right format. For example, if an API expects you to pass an email address and you pass "email": "Luke Skywalker", you’re not passing a valid email - you’re passing a name. Some APIs will tell you the email isn’t a real email address, and the API returns a 400 error with more details.

How do I get more information on 400 errors?

A 400 error refers to the HTTP status code that the API returns, but that doesn’t tell us what’s wrong. Luckily, the API will often return specific information on the error in the HTTP response body. You can use code like this to inspect that response in the Pipedream UI:

const axios = require("axios")

// Example request
// See https://pipedream.com/docs/workflows/steps/code/nodejs/http-requests/
const { data } = await axios({
  url: "https://example.com", // your URL here
  method: "GET" // or "POST", etc.
  validateStatus: () => true
})

return data

When you run this code in a workflow, Pipedream will display the error data below the step. Most pre-built steps will also return information on the error below the step, highlighted in red.

It’s also important to understand that the error is specific to the API, and has nothing to do with Pipedream. The app is telling you that you’re not passing data the way they expect. You can usually find more information on the error by reading the service’s API docs, by Googling the error message, or by reaching out to the API’s community or support team.

If you’re using a Pipedream pre-built step to interact with an API, and you’re still receiving a 400 error even though you’re confident you’re passing data correctly, reach out to our team.

Other resources

  • If you’re still learning about HTTP, we’d recommend reading this article.
  • If you want to make HTTP requests in Node.js, read this guide