<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[HTTP Requests with &#96;maxon&#96; API]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">As mentioned in <a href="https://developers.maxon.net/forum/topic/11775/distributing-python-plugins-that-have-dependencies/7" target="_blank" rel="noopener noreferrer nofollow ugc">this thread</a> I'm looking to bring JSON data into Cinema 4D via HTTP GET request. I noticed in the C++ docs that there's a <a href="https://developers.maxon.net/docs/cpp/2023_2/classmaxon_1_1_network_http_handler_interface.html" target="_blank" rel="noopener noreferrer nofollow ugc">NetworkHttpHandlerInterface Class</a>. I also noticed in the python docs that the <code>maxon</code> API implements a <code>url</code> type.</p>
<p dir="auto">What's the state of these implementations and can they be used to make a connection to an HTTP server and request data? I think I've managed to successfully connect to a remote server, but I can't figure out how to read the data or make more specific requests.</p>
<pre><code class="language-python">"""Name-en-US: Simple HTTP Requests
Description-en-US: Prints the result of connecting to wikipedia.org
"""

import c4d
from c4d import gui

import maxon

def main():
    url = maxon.Url("https://www.wikipedia.org/")
    connection = url.OpenConnection()
    print connection


if __name__=='__main__':
    main()
</code></pre>
<p dir="auto">If it's possible, could someone share some example code for how to use the <code>maxon</code> API to print the results of an HTTP GET request in <code>python</code>. If it's not yet possible, may I request that it be added to the SDK?<br />
Thank you,</p>
<p dir="auto">Donovan</p>
]]></description><link>http://developers.maxon.net/forum/topic/11778/http-requests-with-maxon-api</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 12:17:41 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/11778.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Sep 2019 22:41:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to HTTP Requests with &#96;maxon&#96; API on Wed, 11 Sep 2019 17:26:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m_adam">@<bdi>m_adam</bdi></a> said in <a href="https://developers.maxon.net/forum/post/59290" target="_blank" rel="noopener noreferrer nofollow ugc">HTTP Requests with &amp;#x60;maxon&amp;#x60; API</a>:</p>
<blockquote>
<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/dskeithbuck">@<bdi>dskeithbuck</bdi></a> thanks a lot for trying to use the new Maxon API.</p>
</blockquote>
<p dir="auto">Thank you so much for the working sample code, that answers my question. I look forward to switching over to the Maxon API for URL requests once these kinks get worked out.</p>
]]></description><link>http://developers.maxon.net/forum/post/59296</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/59296</guid><dc:creator><![CDATA[dskeithbuck]]></dc:creator><pubDate>Wed, 11 Sep 2019 17:26:37 GMT</pubDate></item><item><title><![CDATA[Reply to HTTP Requests with &#96;maxon&#96; API on Wed, 11 Sep 2019 17:22:00 GMT]]></title><description><![CDATA[<p dir="auto">@zipit said in <a href="https://developers.maxon.net/forum/post/59284" target="_blank" rel="noopener noreferrer nofollow ugc">HTTP Requests with &amp;#x60;maxon&amp;#x60; API</a>:</p>
<blockquote>
<p dir="auto">I also don't think that your code does establish a connection as you said.</p>
</blockquote>
<p dir="auto">Perhaps you're right, I tried a bunch of different things before landing here. With one of my tests I was getting a 404 error which implied that network requests were being made.</p>
<blockquote>
<p dir="auto">May I also ask why you are not using pythons own <code>urllib</code>? While its reputation is (rightfully) somewhat bad, it certainly will be enough to fetch some JSON.</p>
</blockquote>
<p dir="auto">I'm connecting to a localhost server being run by another application. As I understand it <code>urllib</code> creates a brand new HTTP connection every time I pass data back and forth which is leading to some unfortunate latency. The <code>requests</code> library can make a connection that stays open and all future transactions are much faster.</p>
<p dir="auto">I'm hoping to install this plugin cross-platform on a large number of machines and I want to avoid trying to package <code>requests</code> and all of its dependencies if possible which is why I was excited to see that the <code>maxon</code> API seemed to have some of the same abilities as <code>requests</code>.<br />
Thanks for taking a look!</p>
]]></description><link>http://developers.maxon.net/forum/post/59295</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/59295</guid><dc:creator><![CDATA[dskeithbuck]]></dc:creator><pubDate>Wed, 11 Sep 2019 17:22:00 GMT</pubDate></item><item><title><![CDATA[Reply to HTTP Requests with &#96;maxon&#96; API on Wed, 11 Sep 2019 15:47:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/dskeithbuck">@<bdi>dskeithbuck</bdi></a> thanks a lot for trying to use the new Maxon API.<br />
Unfortunately, the Python Maxon API is not completely ready and still, a lot of things need to be done.</p>
<p dir="auto">While it's somehow possible to read data, due to Python Maxon API specific bugs: HTTPS does not support InputStreamRef.GetStreamLength, InputStreamRef.Read/Write doesn't work.<br />
So even reading currently is not the most intuitive way so I share it, but consider there are actually some bugs/Not yet implemented features that prevents to have the same code than the one used in the <a href="https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_files_url.html" target="_blank" rel="noopener noreferrer nofollow ugc">C++ URL manual</a>.</p>
<pre><code>import maxon

def main():
    # Defines the URL
    url = maxon.Url("https://www.wikipedia.org/")
    
    # Creates an Input Stream (you are going to read)
    inputStream = url.OpenInputStream(maxon.OPENSTREAMFLAGS.NONE)
    
    # Creates a BaseArray or char that will received all the needed content
    data = maxon.BaseArray(maxon.Char)
    data.Resize(100)
    
    # Write the data into data
    inputStream.ReadEOS(data)
    
    # Converts the maxon.BaseArray(maxon.Char) to a list to then convert it to a string
    s = "".join(list(data))
    print s

if __name__=='__main__':
    main()
</code></pre>
<p dir="auto">So yes for the moment the best way is to keep using the python standard module. As you want to use some webstuff I also want to mention you do not forget about <a href="https://developers.maxon.net/forum/topic/11370/c4d-s-python-implementation-on-mac-and-pc/8" target="_blank" rel="noopener noreferrer nofollow ugc">SSL Error in Mac</a>.</p>
<p dir="auto">If you have any question, let me know.</p>
<p dir="auto">And thanks again for poking around with the maxon API in python.<br />
Cheers,<br />
Maxime.</p>
]]></description><link>http://developers.maxon.net/forum/post/59290</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/59290</guid><dc:creator><![CDATA[m_adam]]></dc:creator><pubDate>Wed, 11 Sep 2019 15:47:26 GMT</pubDate></item><item><title><![CDATA[Reply to HTTP Requests with &#96;maxon&#96; API on Wed, 11 Sep 2019 08:57:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I am getting a lot of <code>NotImplementedError</code> when I start poking around, which suggests that things are heavily on the NYI side regarding URLs and StreamInterfaces. I also don't think that your code does establish a connection as you said. You instantiate a connection interface but I could not see any traffic from or to the given URL.</p>
<p dir="auto">May I also ask why you are not using pythons own <code>urllib</code>? While its reputation is (rightfully) somewhat bad, it certainly will be enough to fetch some JSON.</p>
<p dir="auto">Cheers<br />
zipit</p>
]]></description><link>http://developers.maxon.net/forum/post/59284</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/59284</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 11 Sep 2019 08:57:50 GMT</pubDate></item></channel></rss>