Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 3

API Request Returning 502 Persistently

Solved! Go to Solution.

Hello! 

 

I'm using the GitHub API v3 with the Golang SDK.  I'm able to send the other requests in my program, but am having trouble with one call in particular.  Whenever I send a request to get all the repos in an organization, I am getting a 502 Server Error.  I am able to send other calls with that same client, so I don't think that's the issue.  However, I haven't found any potential solutions to this in the documentation.  Any help woud be greatly appreciated!  Below is my function in case it helps: 

 

func getRepos(c *github.Client, org string) []*github.Repository {

	repos, _, err := c.Repositories.ListByOrg(
		context.Background(),
		org,
		&github.RepositoryListByOrgOptions{
			Type: "public",
		},
	)

	if err != nil {
		fmt.Printf("Error getting Repos: %v", err)
	}
	fmt.Printf("Total repos: %v\n", len(repos))
	return repos
}
2 Replies
Copilot Lvl 2
Message 2 of 3

Re: API Request Returning 502 Persistently

Just some more information, I'm able to send the same request through my browser and Postman, and get a successful response of the collection of Repos.  In my case, the org is "kubernetes", and the request is: 

GET https://api.github.com/orgs/kubernetes/repos

 

 

Solution
Ground Controller Lvl 1
Message 3 of 3

Re: API Request Returning 502 Persistently

You are getting bitten by https://github.com/google/go-github/issues/1037. Removing the Accept header values fixed the problem for me.