Learning this trick a couple years ago has saved me so much time, that it’s only prudent for me to share. Hopefully everyone finds it as useful as I have (and use it as often as I have) ?.
We’ve all been there: API is built, along with a front end to consume the awesomeness that is your API. Form is set up to log your user in, hit the send button… and get a 400 response. Wait, what the what? If this is happening to you, there is a simple remedy. With tools you are probably already using.
I use this trick on a daily basis. I hope that you will too!
Chrome & Firefox
This tip involves either Google #Chrome or Mozilla #Firefox (there may be more, but these are the #browsers I use) and the Postman app. These are all free to use, so everyone should. They are awesome!
- Open dev tools/
- Chrome (cmd + alt + i
- Firefox (cmd + alt + i
Go to the network tab.
Find the failing request.
Right click and copy as cURL
Open Postman and select import.
Select the “Paste Raw Test” tab.
Paste cURL request copied from the browser and hit Import.
Send the request for much easier debugging.
One thing to take note of, your request is completely imported into Postman. This makes it very simple to debug. Data is easier to see and headers sent in their nice UI.
Handy for the Front
As a backend dev, I find it handy when frontend devs send that request to me in chat. Allowing me to recreate what is breaking in the API with the exact data that they are sending.