Api page is blank with no errors

I have installed gitea 1.9.6 64bit on Windows Server 2012 R2.

  • I created the sqlite database like the documentation says.
  • Created the folders, data, custom, lfs, log.
  • I have gone through the setup. I can create organizations, repos in the organizations, push files, pull files, etc.
  • LDAP is binding to Active Directory

But when I go to /api/swagger to see the documentation, I am getting a blank page. F12 tells me that the page is trying to load swagger.v1.json. And if I change the url to that, the browser downloads that file, and the contents look like the content at Gitea API.

If I use curl to try to call one of the APIs, I am getting this response:
{“documentation_url”:“http://gitserv:3000/api/swagger",“errors”:null,“message”:"Not Found”}

I created a token under my user and have included the token with -H “Authorization: token abcd…”

I have the ini file section [api] set with ENABLE_SWAGGER = true. I also see the documentation saying that I shouldn’t need that setting because it defaults to true.

I am stumped as the next step to enable the REST API.

Hello and welcome!

First, Gitea is currently at 1.11.3 and we strongly recommend updating to get the latest features, security fixes, etc.

Are there any errors in the logs? The response you got from curl is an error given by the API, though it is saying it cannot find the endpoint you want.
When you see the blank page, are you on http://gitserv:3000/api/swagger?

I realized that when I downloaded the exe, that I did the normal scroll to the bottom and saw that 1.9.6 was the latest. I have since realized the error of my ways and I see that 1.11.3 is the latest. I have downloaded that exe and replaced the existing one.

I also noticed that the [api] section was duplicated in my ini file. That is also corrected.

I made these two changes, and the /api/swagger url now shows the swagger UI!

I still fail in calling an API though.

What error is it returning now?

I stepped away, went around petted the dogs in the office, came back and took a fresh look.

curl ://server:3000/api/v1/org -H “Authorization: token abcd” -H “accept: application/json”

{“documentation_url”:“htnotlinktp://gitserv:3000/api/swagger”,“errors”:null,“message”:“Not Found”}

Lets find a simpler one:
curl htnotlinktp://gitserv:3000/api/v1/version
{“version”:“1.11.3”}

oh. hmm.

curl htnotlinktp://gitserv:3000/api/v1**/admin/orgs** -H “Authorization: token abcd…” -H “accept: application/json”

Ok, I see that I had org instead of orgs and completely missing /admin/.

Summary:

  1. Check ini file for duplicate section headers
  2. Check the FULL URL path you are trying to make