#help (2023-01)

Where to get help about getting help!

2023-01-16

omkarhalankar avatar
omkarhalankar

hi @Erik Osterman (Cloud Posse) I am using GitHub Enterprise and trying to figure out what exactly is GITHUB_UPLOAD_URL / uploadURL ? can anyone help me around this? This seems to be a mandatory flag while using baseURL Anyone who can help me with this ?

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

Please provide context :-) is this a GitHub Action or terraform module?

omkarhalankar avatar
omkarhalankar

sorry for that. @Erik Osterman (Cloud Posse) its about https://github.com/cloudposse/github-commenter since I’m using GitHub Enterprise for GitHub Commenter and will be passing BaseURL , its mandatory to pass Upload URL. The description in the documentation around Upload URL doesnt give me a clear picture what exactly it requires. Some example will be helpful.

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

base URL and upload URL are for GitHub enterprise

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)
// NewEnterpriseClient returns a new GitHub API client with provided
// base URL and upload URL (often is your GitHub Enterprise hostname).
// If the base URL does not have the suffix "/api/v3/", it will be added automatically.
// If the upload URL does not have the suffix "/api/uploads", it will be added automatically.
// If a nil httpClient is provided, a new http.Client will be used.
//
// Note that NewEnterpriseClient is a convenience helper only;
// its behavior is equivalent to using NewClient, followed by setting
// the BaseURL and UploadURL fields.
//
// Another important thing is that by default, the GitHub Enterprise URL format
// should be http(s)://[hostname]/api/v3/ or you will always receive the 406 status code.
// The upload URL format should be http(s)://[hostname]/api/uploads/.
func NewEnterpriseClient(baseURL, uploadURL string, httpClient *http.Client) (*Client, error) {
Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)
GitHub Enterprise Cloud expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body
Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

for GH Enterprise, the base URL is different

The baseURL of the public facing API is simply: <https://api.github.com/>"
However for enterprise Github instances the baseURL for the API is slightly different: https://github.com/api/v3/"

Using a baseURL without the /api/v3/ suffix will result in HTTP 406 Not Acceptable errors and lead you down a path of debugging Oauth clients and request headers. I learnt this after many hours and tears.
Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

and it requires a separate upload URL to upload assets in binary format

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

so base URL is your GitHub Enterprise hostname + /api/v3/

Andriy Knysh (Cloud Posse) avatar
Andriy Knysh (Cloud Posse)

the upload URL is your GitHub Enterprise hostname + /api/uploads/

1
omkarhalankar avatar
omkarhalankar

Thanks @Andriy Knysh (Cloud Posse)! this is helpful.

    keyboard_arrow_up