400 Bad Request on Postmark API

Hello folks,

I am trying to use Postman to query Postmark’s free DMARC API at API Docs | Free DMARC Monitoring from Postmark

I’ve setup Postman to replicate what I used to curl manually, but when I run it with Postman I get a 400 Bad Request. If I copy and paste the cURL code snippet that Postman generated into Terminal on macOS, the query succeeds. What is Postman doing different that causes the call to fail?

curl -L -X GET 'https://dmarc.postmarkapp.com/records/my' \
-H 'Accept: application/json' \
-H 'X-Api-Token: MY_TOKEN'

Hi @descent-module-engi3

Could you screenshot what your Postman looks like?
(Delete / Don’t share your X-Api-Token in the screenshot).

Pretty simple…


Just read this in the documentation;

All requests to Postmark’s API require you to authenticate yourself to the service. In order to do this you must send the correct HTTP header with the correct API token. Postmark has two types of API tokens:

  • Server Token — X-Postmark-Server-Token Used for requests that require server level privileges. This token can be found from the API Tokens tab under your Postmark server.
  • Account Token — X-Postmark-Account-Token Used for requests that require account level privileges. This token is only accessible by the account owner, and can be found on the API Tokens tab of your Postmark account.

This is separate from the PM API you have added already.

Also, I can’t find any reference to https://dmarc.postmarkapp.com/records/my in the documentation… Might be worth checking the URL against the available options in the atached documentation;

Example;

You’re looking at the docs for the main Postmark product, not their free DMARC service, those docs are here → API Docs | Free DMARC Monitoring from Postmark as posted on my original post

My bad …

For your {{PM_FM}} variable, have you used a Postman API key or a DMARC API key?

This orange dot also means you haven’t saved your changes… which could explain why its not sending the right request.

image

You could also verify what it is actually sending in the console, located in the bottom left.

Thanks for the console tip! Didn’t get much insight though? I did save it before hand, and yes, of course I’m using the Postmark key. It works via terminal, just not via Postman. Was hoping to automate some of my tasks.

My initial thoughts is that the problem is still something to do with the headers.

The blurb from the API documentation says it could be malformed JSON although it doesn’t appear that the get request against the /records/my end point request requires a JSON body or any other parameters than the two you’ve included.

Can you try a post request which doesn’t require authentication?

This does require a JSON request in the body. For example…

{
  "email": "[email protected]",
  "domain": "activecampaign.com"
}