0

I´m working for a bigger company and we have the enterprise version available. We´ve created an organization and now I want to create Repositories with the octokit API client.

Directly with Postman it works like that (it works perfectly)

    Request Headers
    Authorization: Bearer <personal api token>
    Content-Type: application/json
    User-Agent: PostmanRuntime/7.32.3
    Accept: */*
    Postman-Token: <postman-token>
    Host: <our host>
    Accept-Encoding: gzip, deflate, br
    Connection: keep-alive
    Content-Length: 253
    Request Body
    {
        "name": "Hello-World2",
        "description": "This is your first repository",
        "homepage": "https://github.com",
        "private": false,
        "has_issues": true,
        "has_projects": true,
        "has_wiki": true,
        "visibility": "internal"
    }

Then I´ve tried that with octokit with that method

    <surrounding code>
            const createResult = await octoClient.rest.repos.createInOrg({
                ...params,
                org: orga,
                team_id: params.teamId,                 
    
            });

Params are:

    const newRepoDescriptor: githubRepositoryCreationType = {
                    name: 'automation-test-3',
                    description: "automation-test-1",
                    homepage: "",
                    private: false,
                    has_issues: true,
                    has_projects: true,
                    has_wiki: true,
                }

I can´t set the visibility to "internal" like in the direct call, because octokit only accepts "private" or "public" here.

I create the client object with

    export const octoClientBaseParams = {
        auth: process.env.GITHUB_TOKEN,
        log: require("console-log-level")({ level: "debug" }),
        baseUrl: "https://<myhost>/api/v3",         
    }
    
    const myOctokit = Octokit.plugin(paginateRest);
    
    export const octoClient:Octokit = new myOctokit(octoClientBaseParams);

How can I create a internal repository in my organization, then ?

Thanks and Greetings,

JP

Versions

"@octokit/plugin-paginate-rest": "^7.1.2",
"@octokit/rest": "^19.0.13",

node --version

v16.14.0
wayne
  • 393
  • 2
  • 13
Wurzelseppi
  • 95
  • 1
  • 10

0 Answers0