Replies: 4 comments 1 reply
-
If you look at the Writing Extensions tutorial, the best practice is to use the plugin toolkit so you can pass the authorization context. Alternatively, I've found it easier to use the ckanapi python module. Also, please close #6316, as Discussions is the right place to post questions and the Issue Tracker is for bug reports. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your advice. At least I was now able to create new packages via the toolkit.get_action() function but couldn't create new resources. So this is working now:
While this leads to the following error:
Any idea how to fix this? Btw, also with the ckanapi python module I cannot create resources - using RemoteCKAN leads to the exact same connection error like in the original post |
Beta Was this translation helpful? Give feedback.
-
Can you try adding Also, any particular reason you're using Python 2.7 now that its EOL and CKAN 2.9 supports Python 3? As for ckanapi, have you tried using this particular snippet against your installation? |
Beta Was this translation helpful? Give feedback.
-
I am closing this discussion as I chose another approach without creating an own extension. @jqnatividad Thank you anyway, the reference to the ckanapi module was quite useful and is working for me now (outside my extension code). EDIT: Ok, just saw I cannot close a discussion, but just wanted to say that I don't need help on this issue anymore ;) |
Beta Was this translation helpful? Give feedback.
-
I just wanted to make some test API requests (like https://docs.ckan.org/en/2.9/api/index.html#making-an-api-request or https://docs.ckan.org/en/2.9/api/index.html#example-importing-datasets-with-the-ckan-api) within my CKAN extension but I always get an error that the connection was refused when using the urllib2 library.
urllib2.URLError: <urlopen error [Errno 111] Connection refused>
What makes it a bit confusing for me: When I run the correpsonding commands on the command line with curl (for example to create a package or a dataset) everthing works without any errors, so the URL seems to be correct/accessible. The URL by the way is the same as
ckan.site_url
.To summarize it:
This works (via command line):
curl -X POST http://<SERVER_IP>:5000/api/3/action/package_create
....This leads to the error from above when calling
urllib2.urlopen
(code line in my extension):urllib2.Request("http://<SERVER_IP>:5000/api/3/action/package_create")
Could it be a problem that I want to call the CKAN API within my CKAN extension? The authorization/API key should be fine..
Would be thankful for any feedback/input why I cannot access the API within my extension.
Beta Was this translation helpful? Give feedback.
All reactions