Accept Github repository invitation

Hi,

I was looking at the Github API and it allows you to fetch all repository invites through an API endpoint (see https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository). This works fine like this:

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))

I can then get out each request its url like this:

for repository_invite in repository_invites:
print('url: ' + repository_invite.get('url'))

Which gives something back like:

url: https://api.github.com/user/repository_invitations/123456789

Github also mentions that you can accept an invite at https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation which mentions
> PATCH /user/repository_invitations/:invitation_id

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 PATCH at https://developer.github.com/v3/#http-verbs which mentions you can use either a POST or send a PATCH request, however not how. So the question is, how do I know what I should send in the PATCH call? I tried this for example:

result = requests.patch(repository_invite.get('url'), json.dumps({'accept': True}))
print('result: ' + str(result.json()))

Which gives back:

result: {'message': 'Invalid request.\n\n"accept" is not a permitted key.', 'documentation_url': 'https://developer.github.com/v3'}

So, how exactly can I call this endpoint?

We use this API successfully, but through octokit rest.js… it is a PATCH to the invitation ID, but no other parameters.

So you literally just issue a PATCH to that URL you retrieved, no parameters… try that?

Is there any way to do this if you can’t send a PATCH method?  I’m using standard JDK http connection and it doesn’t support PATCH method (in my code I don’t have opition to use a apache httpclient library which supports non standard methods such as PATCH).

According to this: https://developer.github.com/v3/#http-verbs I should be able to do a POST instead of a PATCH, but that doesn’t seem to be working, or either I’m not "POST"ing correctly.

I’d like to hear from anyone who has gotten a “POST” to work for accepting a repo invite.  Thanks!