Import from GitHub enterprise via API fails with error: `Import failed due to a GitHub error: (HTTP 406)`
<!---
Please read this!
Before opening a new issue, make sure to search for keywords in the issues
filtered by the "regression" or "type::bug" label:
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug
and verify the issue you're about to submit isn't a duplicate.
--->
### Summary
GitLab returns the error: `Import failed due to a GitHub error: (HTTP 406)` when trying to import a project from GitHub enterprise server via the [import API](https://docs.gitlab.com/ee/api/import.html#import-repository-from-github). Importing the project via UI works fine.
This works fine with GitLab 16.2 and earlier.
### Steps to reproduce
Use the [Import API](https://docs.gitlab.com/ee/api/import.html#import-repository-from-github) to import a project.
### Example Project
<!-- If possible, please create an example project here on GitLab.com that exhibits the problematic
behavior, and link to it here in the bug report. If you are using an older version of GitLab, this
will also determine whether the bug is fixed in a more recent version. -->
### What is the current *bug* behavior?
Importing projects from GitHub enterprise server via the Import API results in HTTP 406 error.
### What is the expected *correct* behavior?
Import via API should succeed.
### Relevant logs and/or screenshots
API call response: `Import failed due to a GitHub error: (HTTP 406)`.
This bug was originally reported by one of our customers through the ticket: https://gitlab.zendesk.com/agent/tickets/490604 (internal use). They were kind enough to run a packet capture of outgoing requests from GitLab 16.2.1 and 16.7.3. In the pcap output, we can see that v16.2.1 requests for the repositories with path `/api/v3/repositories/<id>` while v16.7.2 misses out on the `/api/v3` prefix. See the following pcap for details:
v16.2.1:
```bash
11:11:20.472096 IP x.x.x.234.53752 > x.x.x.239.http: Flags [P.], seq 1:288, ack 1, win 8212, length 287: HTTP: GET /api/v3/repositories/1 HTTP/1.1
11:11:20.514584 IP x.x.x.239.http > x.x.x.234.53752: Flags [.], ack 288, win 42, length 0
11:11:20.565307 IP x.x.x.239.http > x.x.x.234.53752: Flags [P.], seq 1:2674, ack 288, win 42, length 2673: HTTP: HTTP/1.1 200 OK
```
v16.7.3:
```bash
10:38:51.821722 IP x.x.x.234.49892 > x.x.x.239.http: Flags [P.], seq 1:324, ack 1, win 8212, length 323: HTTP: GET /login?return_to=http%3A%2F%2Fx.x.x.239%2Frepositories%2F1 HTTP/1.1
10:38:51.836940 IP x.x.x.239.http > x.x.x.234.49892: Flags [.], seq 1:1461, ack 324, win 42, length 1460: HTTP: HTTP/1.1 406 Not Acceptable
```
### Output of checks
<!-- If you are reporting a bug on GitLab.com, uncomment below -->
<!-- This bug happens on GitLab.com -->
<!-- /label ~"reproduced on GitLab.com" -->
#### Results of GitLab environment info
<!-- Input any relevant GitLab environment information if needed. -->
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
</pre>
</details>
#### Results of GitLab application Check
<!-- Input any relevant GitLab application check information if needed. -->
<details>
<summary>Expand for output related to the GitLab application check</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:check SANITIZE=true`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`)
(we will only investigate if the tests are passing)
</pre>
</details>
### Possible fixes
The path prefix `api/v3` got dropped from the GitHub Import on 16.5 when the importer [stopped using Gitlab::LegacyGithubImport::Client](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/132544) which automatically [adds the prefix](https://gitlab.com/gitlab-org/gitlab/-/blob/cf5a07f5d54fac8fbe1ccc39a68e84cc97545591/lib/gitlab/legacy_github_import/client.rb#L101) when importing from a GitHub Enterprise URL
To fix the problem, we should add the prefix when importing from a GitHub Enterprise URL and update the GitHub Import API documentation mentioning that users should manually add the prefix when importing using a GitLab version from 16.5 to 17.1
Docs first update: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/158330+ - will have to be changes slightly when the issue is fixed.
### Workaround
https://gitlab.com/gitlab-org/gitlab/-/issues/438358#note_1978902725
issue