From b334ee1f2028a0a24154539ec5da3f5be80595fc Mon Sep 17 00:00:00 2001 From: Javier Tello <49450112+javier-tello@users.noreply.github.com> Date: Tue, 2 Mar 2021 17:06:54 -0500 Subject: [PATCH] [ESN-2880] Update Python API example to python3 (#4) * Update API pythoon example to python3 * Update sample Python Example based on feedback changed import to urllib.request and included json library to easier parse response * Fix indentation Co-authored-by: Jay Guo --- ckanext/odata/templates/ajax_snippets/api_info.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ckanext/odata/templates/ajax_snippets/api_info.html b/ckanext/odata/templates/ajax_snippets/api_info.html index c02c51b..33b1eb1 100644 --- a/ckanext/odata/templates/ajax_snippets/api_info.html +++ b/ckanext/odata/templates/ajax_snippets/api_info.html @@ -138,11 +138,13 @@

-import urllib
+import json
+import urllib.request
 url = '{{ h.url_for(qualified=True, controller='api', action='action', ver=3, logic_function='datastore_search', resource_id=resource_id, limit=5) + '&q=title:jones' }}'  {# not urlencoding the ":" because its clearer #}
-fileobj = urllib.urlopen(url)
-print fileobj.read()
-
+fileobj = urllib.request.urlopen(url) +response_dict = json.loads(fileobj.read()) +print(response_dict) +