How create new repo via Phabricator API

I want to create a batch of Repository in Phabricator. These repo already created in gitlab, So i want to just export them into Phabricator via APIs. But i didn’t find those APIs worked for this. i could do this manually via Phab UI, like this, while it is not efficient for batch of repository.

api_parameters = [
        {"type": "uri", "value": "ssh://git@test/test.git"},
        {"type": "io", "value": "Observe"},
        {"type": "repository", "value": ""},
        {"type": "name", "value": "TEST"},
    ]

    res = requests.post(CREATE_REPO_URL, data={"api.token": TOKEN, "api_parameters": api_parameters})

I tried this, but error.

b'{"result":null,"error_code":"ERR-CONDUIT-CALL","error_info":"API Method \\"diffusion.repository.edit\\" does not define these parameters: \'type\'."}'

diffusion.repository.edit is the right API call, but this is not how you invoke it.

Visit your install’s https://<phabricator>/conduit/method/diffusion.repository.edit/, and enter the values there, and submit.
Then, at the bottom of the page, you’ll see examples on how to make this call using Arcanist or using cURL.

Hello !

I try with curl to create a repo and it does not work :frowning:

curl https://my-url/api/diffusion.repository.edit \
    -d api.token=api-my-token-here \
    -d transactions[0][type]=vcs \
    -d transactions[0][value]=git \
    -d transactions[1][type]=name \
    -d transactions[1][value]=testingrepocreation

Result is
zsh: no matches found: transactions[0][type]=vcs

Also,
second question: is there a programatic way to create conduit-api-token , via curl or something ?

That sounds like your shell zsh is not interpreting your command-line properly. You likely need to wrap all the transactions...=vcs in quotes.

zsh: no matches found: transactions[0][type]=vcs

zsh is trying to parse this string as some internal zsh expression, and fails.
Wrap it with ':
-d 'transactions[0][value]=git' \

I don’t think there’s an API to get a token.

Many thanks !
I will paste here the command to let others know also:

curl -k -s -X POST https://URL/api/diffusion.repository.edit \
-d api.token=api-TOKEN_HERE \
-d 'transactions[0][type]=vcs' \
-d 'transactions[0][value]=git' \
-d 'transactions[1][type]=name' \
-d 'transactions[1][value]=testing' | jq -r

{
  "result": {
    "object": {
      "id": 6,
      "phid": "PHID-REPO-ku3ko6sbypgrj74jlmoc"
    },
    "transactions": [
      {
        "phid": "PHID-XACT-REPO-x5ghklvhlqeo46g"
      },
      {
        "phid": "PHID-XACT-REPO-eol7rgevm4aenhl"
      },
      {
        "phid": "PHID-XACT-REPO-7lmqyneu3ij5cdi"
      }
    ]
  },
  "error_code": null,
  "error_info": null
}