Danbooru

API Requests Returning 200 on Postman but 403 on my Application

Posted under Bugs & Features

Hello. I recently started using the Danbooru API and have came across a bug I haven't resolved for several days.

So, I started by using Postman to test each endpoint I needed like /tags.json and /posts.json. With my API key and login, I am able to flawlessly request data with a 200 status code along with the appropriate parameters to query what I need.

However, when I move to my C# Discord bot for a sauce command, every request I've attempted to make with the same parameters and same credentials returns a 403: Forbidden code. The request urls are exactly the same and even when I try simply copying and pasting the request url, the JSON data returns.

Steps I Made to Approach this Issue:

  • Ensured my API key had the appropriate permissions (which were labeled as All).
  • Regenerated another API key.

And none of these worked.

Any help with this issue would be highly appreciated!

mikf said:

Try sending a proper User-Agent header with your requests.
Something like User-Agent: ApplicationName/1.0

Yup, I was able to figure this out by referencing someone else who also was having this issue by using agent Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com). But thanks still!

crobati said:

Yup, I was able to figure this out by referencing someone else who also was having this issue by using agent Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com). But thanks still!

@crobati, did someone else have that problem while using that user agent or did you fix your problem by switching to using that user agent? If it’s the latter, I suggest changing your user agent to something unique. “Discordbot” isn’t particularly unique and I don’t think discordapp.com is your site. You should either come up with some actually unique name for your app/bot or just use something simple like “Danbooru user crobati”, which is actually the variant recommended by evazion.

kittey said:

@crobati, did someone else have that problem while using that user agent or did you fix your problem by switching to using that user agent? If it’s the latter, I suggest changing your user agent to something unique. “Discordbot” isn’t particularly unique and I don’t think discordapp.com is your site. You should either come up with some actually unique name for your app/bot or just use something simple like “Danbooru user crobati”, which is actually the variant recommended by evazion.

It's more of that I checked out what they had for their user agent and copied the exact agent. After I found it did, then I went to change it to the name of the bot and a domain I own.

1