Skip to content

Instantly share code, notes, and snippets.

@idokd
Last active November 1, 2021 18:29
Show Gist options
  • Select an option

  • Save idokd/80da721643a102ec4f5f8411b1712e9b to your computer and use it in GitHub Desktop.

Select an option

Save idokd/80da721643a102ec4f5f8411b1712e9b to your computer and use it in GitHub Desktop.
Github Repository Ownership Transfer via Postman
# This script is to be used in Postman if you wish to transfer ownership of your repository in a batch
# Example; downgrading from organization account (25usd min) to pro user (7usd) monthly and keeping all
# your private repositories
# Instead of complicate with scripts etc. just use postman
# the repos api will list only 25 at a time, so you should run this script a few times if you have more
# repositories to transfer
GET /orgs/### CURRENT OWNER REPOSITORY ###/repos HTTP/1.1
Host: api.github.com
Authorization: token ### GITHUB API TOKEN HERE ###
Code in Tests:
var repos = pm.response.json();
repos.forEach(function(repos) {
var owner = repos.owner.login;
var name = repos.name;
var endpoint = "https://api.github.com";
var post = "/repos/" + owner + "/" + name + "/transfer"
console.log(post );
var request = {
url: endpoint + post,
method: 'POST',
header: ['Accept:application/vnd.github.nightshade-preview+json', 'Authorization:token ### GITHUB API TOKEN HERE ###'],
body: {
mode: 'raw',
raw: JSON.stringify({
"new_owner": "### DESTINATION OWNER USERNAME HERE ###"
})
}
};
pm.sendRequest(request, function (err, response) {
console.log(response.json());
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment