put - Starring a repository with the github API -


i'm trying star repository using githubapi. done via put request /user/starred/:owner/:repo. attempted implement feature in python using requests library, isn't working. here minimum working example:

the constant defined github_api = api.github.com, github_user = username of owner of repo starred, , github_repo = name of repo starred

url = urljoin(github_api, (user + '/starred/' + github_user + '/' + github_repo)) r = requests.put(url,auth=(user,password)) print r.text 

this code results in error reads:

{"message":"not found","documentation_url":"https://developer.github.com/v3"} 

i think i'm missing fundamental process of issuing put request.

the problem here parameters pass urljoin(). first parameter supposed absolute url, while second parameter relative url. urljoin() creates absolute url that.

also, "user" in case supposed literal part of url, , not username.

in case, forgo urljoin()-function completely, , instead use simple string substitution:

url = 'https://api.github.com/user/starred/{owner}/{repo}'.format(           owner=github_user,           repo=github_repo       ) 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -