Last active
April 5, 2024 17:38
-
-
Save joshisumit/35e9ee3e68e5210af331 to your computer and use it in GitHub Desktop.
Revisions
-
joshisumit revised this gist
Jan 10, 2016 . No changes.There are no files selected for viewing
-
joshisumit revised this gist
Jan 9, 2016 . No changes.There are no files selected for viewing
-
joshisumit revised this gist
Jan 9, 2016 . 2 changed files with 38 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ ''' HTTP Reuests has following parameters: 1)Request URL 2)Header Fields 3)Parameter 4)Request body ''' #!/usr/bin/env python import requests import json GITHUB_API="https://api.github.com" API_TOKEN='your_token_goes_here' #form a request URL url=GITHUB_API+"/gists" print "Request URL: %s"%url #print headers,parameters,payload headers={'Authorization':'token %s'%API_TOKEN} params={'scope':'gist'} payload={"description":"GIST created by python code","public":True,"files":{"python request module":{"content":"Python requests has 3 parameters: 1)Request URL\n 2)Header Fields\n 3)Parameter \n4)Request body"}}} #make a requests res=requests.post(url,headers=headers,params=params,data=json.dumps(payload)) #print response --> JSON print res.status_code print res.url print res.text j=json.loads(res.text) # Print created GIST's details for gist in range(len(j)): print "Gist URL : %s"%(j['url']) print "GIST ID: %s"%(j['id']) -
joshisumit created this gist
Jan 9, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ Python requests has 3 parameters: 1)Request URL 2)Header Fields 3)Parameter 4)Request body