'importing repos to github from curl results in 404 response

i am trying to use the curl command for github importer to import repositories from tfs (as git), following github's documentation when i am running this command, i get a 404 response:

curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json"\
-H "Authorization: token {MY_GITHUB_TOKEN}" \
https://api.github.com/repos/{MY-ORGANIZATION}/{REPO_NAME}/import \
-d '{"vcs":"git","vcs_url":"{TFS_REPO_URL}","vcs_username":"{TFS_USER_NAME}","vcs_password":"{TFS_PAT"}'

when i run the importer from the ui in github, everything works.

when i run a curl command to check the import status (for the repo i imported from the ui), i get a valid response:

curl \
  -H "Accept: application/vnd.github.v3+json" \
  -H "Authorization: token {MY_GITHUB_TOKEN}" \
  https://api.github.com/repos/{MY-ORGANIZATION}/{REPO_NAME}/import

what is the missing piece?



Solution 1:[1]

so apparently the importer works differently from the ui and from the api: when running the importer from curl we first need to create a repo in github and only then we can import it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1