Sending request with requests

headers = {"Authorization": "token %s" % token} repos_url = 'https://api.github.com/user/repos' data = { "name": "Hello-World", "description": "This is your first repository", "homepage": "https://github.com", "private": False, "has_issues": True, "has_projects": True, "has_wiki": True } t = requests.get(repos_url,data=data,headers=headers) print (t.json) 

I get the answer <bound method Response.json of <Response [200] . What could be the reason?

Closed due to the fact that off-topic participants andreymal , 0xdb , Sasha Chernykh , Twiss , AivanF. Apr 11 '18 at 6:40 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - andreymal, 0xdb, Sasha Chernykh, Twiss, AivanF.
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    You forgot to call the method: print(t.json()) - andreymal

1 answer 1

I found myself a few mistakes.

  1. print (t.json) - skipped parentheses ().
  2. instead of a get request, you must send a post
  3. data needs to be dumped in json data = json.dumps (data)
  • you can: json=data transfer. For completeness, you can add: headers.update({'Accept': 'application/vnd.github.v3+json'}) - jfs