title: How to accept a Github repository invitation through API?
body: <p>I was looking at the Github API and it allows you to fetch all repository invites through an API endpoint (see <a href="https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository" rel="noreferrer">https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository</a>). This works fine like this:</p>
  
  <pre><code>from requests.auth import HTTPBasicAuth
  import requests
  login = 'xxx'
  password = 'yyy'
  url = 'https://api.github.com/user/repository_invitations'
  repository_invites = requests.get(
              url, auth=HTTPBasicAuth(login, password)).json()
  print('response: ' + str(repository_invites))
  
  </code></pre>
  
  <p>I can then get out each request its <code>url</code> like this:</p>
  
  <pre><code>for repository_invite in repository_invites:
      print('url: ' + repository_invite.get('url'))
  </code></pre>
  
  <p>Which gives something back like:</p>
  
  <pre><code>url: https://api.github.com/user/repository_invitations/123456789
  </code></pre>
  
  <p>Github also mentions that you can accept an invite at <a href="https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation" rel="noreferrer">https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation</a> which mentions</p>
  
  <blockquote>
    <p>PATCH /user/repository_invitations/:invitation_id</p>
  </blockquote>
  
  <p>What I don't get is how I can tell Github how to accept it though. This endpoint seems to be used for both deleting and accepting an invitation. Github talks about <code>PATCH</code> at <a href="https://developer.github.com/v3/#http-verbs" rel="noreferrer">https://developer.github.com/v3/#http-verbs</a> which mentions you can use either a <code>POST</code> or send a <code>PATCH</code> request, however not how. So the question is, how do I know what I should send in the <code>PATCH</code> call? I tried this for example:</p>
  
  <pre><code>result = requests.patch(repository_invite.get('url'), json.dumps({'accept': True}))
      print('result: ' + str(result.json()))
  </code></pre>
  
  <p>Which gives back:</p>
  
  <pre><code>result: {'message': 'Invalid request.\n\n"accept" is not a permitted key.', 'documentation_url': 'https://developer.github.com/v3'}
  
  </code></pre>