Getting a 400 Bad request from cloudflare when trying to create a customer

Hello. I am a bit perplexed here, as I am looking at the output from the request I am sending from my go code and comparing it to the Postman collection and not seeing any differences. However in Postman, the request works, where as from the go code I get an HTML 400 response from cloudflare.

Here is the request dump from the go code:

POST /customers HTTP/1.1
Host: api-sandbox.dwolla.com
Accept: application/vnd.dwolla.v1.hal+json
Authorization: Bearer 5b0GMzxZGqoGEikzzuVh65vQuhcHpyuMYy9x4kpGuLW1GwJdsT
Content-Type: application/vnd.dwolla.v1.hal+json
{
   "firstName":"Receive",
   "lastName":"UserPerson",
   "email":"receive@fake.com",
   "type":"receive-only",
   "businessName":"Some agent"
}

Which seems like everything is correct to match the documentation:

And that identical request goes through via postman.

Another note is that when I send this request alone, with a hardcoded bearer token it works. But if I run a bit of code where I:

  1. try the request
  2. if I get a 401 re-authenticate
  3. re-try the request with the new bearer token

It produces this issue.

Is this a rate limit thing where I am hitting the endpoint back to back too quickly? If it was I would hope for a 429 status code

Hi @mattholdefer , You’re right, rate limit status codes will return a 429 so I don’t believe that is what is going on here. You’d also have to be hitting the API pretty hard (e.g. 10,000 requests within 10 seconds) in order to hit that rate limit. A 400 typically is the result of a BadRequest or ValidationError…something that is wrong with the request body itself.

I do see some 400 requests from your app in Sandbox but I’m not sure which one I should be digging into. Do you have a timestamp of the request that resulted in this error?

Thanks for the quick response, I just repro’d it again to get a timestamp:

2023-04-04 10:47:08.948562 -0400 EDT m=+0.751307668
POST /customers HTTP/1.1
Host: api-sandbox.dwolla.com
Accept: application/vnd.dwolla.v1.hal+json
Authorization: Bearer 2ecx2OkSxf3cNJ98Y0MiLaXk0LIUTEH5z13K4z3dDBV36veM4b
Content-Type: application/vnd.dwolla.v1.hal+json

and the response I get is:

<head>
   <title>400 Bad Request</title>
</head>
<body>
   <center>
      <h1>400 Bad Request</h1>
   </center>
   <hr>
   <center>cloudflare</center>
</body>
</html>

So it seems like the request isn’t even reaching your server, so I don’t know if you would see it in the logs. I think you might have to check the cloudflare logs to see what is happening.