<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Doing_POSTs_with_Python_Modules</id>
	<title>Doing POSTs with Python Modules - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Doing_POSTs_with_Python_Modules"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Doing_POSTs_with_Python_Modules&amp;action=history"/>
	<updated>2026-05-18T15:05:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Doing_POSTs_with_Python_Modules&amp;diff=4897&amp;oldid=prev</id>
		<title>PeterHarding: /* With basic Authentication */</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Doing_POSTs_with_Python_Modules&amp;diff=4897&amp;oldid=prev"/>
		<updated>2017-08-02T05:23:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;With basic Authentication&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:23, 2 August 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l44&quot;&gt;Line 44:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 44:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==With &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;basic &lt;/del&gt;Authentication==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==With &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;SSL Basic &lt;/ins&gt;Authentication==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l93&quot;&gt;Line 93:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 93:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     #print e.read()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     #print e.read()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Doing a POST==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Doing a POST==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Doing_POSTs_with_Python_Modules&amp;diff=4896&amp;oldid=prev</id>
		<title>PeterHarding: Created page with &quot; ==HTTPS GET to https://api.aasdev.net/api/ONLINE/Questions/==  &lt;pre&gt; #!/usr/bin/env python   import ssl import base64 import urllib2   from urllib2 import Request, urlopen, U...&quot;</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Doing_POSTs_with_Python_Modules&amp;diff=4896&amp;oldid=prev"/>
		<updated>2017-08-02T05:23:26Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; ==HTTPS GET to https://api.aasdev.net/api/ONLINE/Questions/==  &amp;lt;pre&amp;gt; #!/usr/bin/env python   import ssl import base64 import urllib2   from urllib2 import Request, urlopen, U...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
==HTTPS GET to https://api.aasdev.net/api/ONLINE/Questions/==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import ssl&lt;br /&gt;
import base64&lt;br /&gt;
import urllib2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
from urllib2 import Request, urlopen, URLError, HTTPError&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ctx = ssl.create_default_context()&lt;br /&gt;
ctx.check_hostname = False&lt;br /&gt;
ctx.verify_mode = ssl.CERT_NONE&lt;br /&gt;
&lt;br /&gt;
request = Request(&amp;#039;https://api.aasdev.net/api/ONLINE/Questions/?Auth=Yes&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    #r = urlopen(req, context=ctx)&lt;br /&gt;
    response = urlopen(request, context=ssl._create_unverified_context())&lt;br /&gt;
&lt;br /&gt;
    response_data = response.read()&lt;br /&gt;
    status_code   = response.code&lt;br /&gt;
&lt;br /&gt;
    print status_code&lt;br /&gt;
    print response_data&lt;br /&gt;
&lt;br /&gt;
except URLError, e:&lt;br /&gt;
&lt;br /&gt;
    if hasattr(e, &amp;#039;reason&amp;#039;):&lt;br /&gt;
        print &amp;#039;We failed to reach a server.&amp;#039;&lt;br /&gt;
        print &amp;#039;Reason: &amp;#039;, e.reason&lt;br /&gt;
    elif hasattr(e, &amp;#039;code&amp;#039;):&lt;br /&gt;
        print &amp;quot;The server couldn&amp;#039;t fulfill the request.&amp;quot;&lt;br /&gt;
        print &amp;#039;Error code: &amp;#039;, e.code&lt;br /&gt;
    else:&lt;br /&gt;
        pass&lt;br /&gt;
&lt;br /&gt;
    #print e.read()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==With basic Authentication==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import ssl&lt;br /&gt;
import base64&lt;br /&gt;
import urllib2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
from urllib2 import Request, urlopen, URLError, HTTPError&lt;br /&gt;
&lt;br /&gt;
username = &amp;#039;plh&amp;#039;&lt;br /&gt;
password = &amp;#039;XXXXX&amp;#039;&lt;br /&gt;
&lt;br /&gt;
auth_encoded = base64.encodestring(&amp;#039;%s:%s&amp;#039; % (username, password))[:-1]&lt;br /&gt;
&lt;br /&gt;
ctx = ssl.create_default_context()&lt;br /&gt;
ctx.check_hostname = False&lt;br /&gt;
ctx.verify_mode = ssl.CERT_NONE&lt;br /&gt;
&lt;br /&gt;
request = Request(&amp;#039;https://api.aasdev.net/api/ONLINE/Questions/?Auth=Yes&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
request.add_header(&amp;#039;Authorization&amp;#039;, &amp;#039;Basic %s&amp;#039; % auth_encoded)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    # response = urlopen(req, context=ctx)&lt;br /&gt;
    response = urlopen(request, context=ssl._create_unverified_context())&lt;br /&gt;
&lt;br /&gt;
    response_data = response.read()&lt;br /&gt;
    status_code   = response.code&lt;br /&gt;
&lt;br /&gt;
    print status_code&lt;br /&gt;
    print response_data&lt;br /&gt;
&lt;br /&gt;
except URLError, e:&lt;br /&gt;
&lt;br /&gt;
    if hasattr(e, &amp;#039;reason&amp;#039;):&lt;br /&gt;
        print &amp;#039;We failed to reach a server.&amp;#039;&lt;br /&gt;
        print &amp;#039;Reason: &amp;#039;, e.reason&lt;br /&gt;
    elif hasattr(e, &amp;#039;code&amp;#039;):&lt;br /&gt;
        print &amp;quot;The server couldn&amp;#039;t fulfill the request.&amp;quot;&lt;br /&gt;
        print &amp;#039;Error code: &amp;#039;, e.code&lt;br /&gt;
    else:&lt;br /&gt;
        pass&lt;br /&gt;
&lt;br /&gt;
    #print e.read()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Doing a POST==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Examples]]&lt;br /&gt;
[[Category:Web]]&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>