Recipes and tools for debugging the API

Heya folks!

I was looking at https://meta.discourse.org/t/api-500-on-user-creation-if-username-is-integer/222281?u=maiki and can only kinda reproduce it, using curl. I’m looking through the docs to see if there is a useful output to capture to assist in figuring out what is happening, and then remember httpie as well…

And then I thought I’d just ping the @support-explorers and ask if they would share tools and recipes they use to debug the API! :sunglasses:

What do you use to troubleshoot and interact with the API?

:computer: :spider_web: :mag:

3 Likes

In general, I am a huge fan of Postman. it helps to emulate API calls and their responses.

3 Likes

I generally use Insomnia or Postman for any API debugging (not just Discourse), I don’t really have any collections to share to speed that up for you though :smiley:

3 Likes

That’s great, that’s what I’m looking for. :slight_smile:

I also use insomnia to get through some wicked problems… :tired_face:

Oh, you meant https://insomnia.rest/! :slight_smile:

(TIL: there is a .rest TLD!)

1 Like

Hi @maiki, thanks for looking into this!

Here’s a CURL request you can use, which was generated from postman (if you’d like). This generates a 500:

curl --location --request POST 'https://XXX.com/users.json' \
--header 'Api-Key: XXX' \
--header 'Api-Username: XXX' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "XXX",
    "email": "XXX@mail.com",
    "password": "aTestPAssword",
    "username": 1,
    "active": true,
    "approved": true
}'
2 Likes