ckan / ckanext-googleanalytics

CKAN extension to integrate Google Analytics data into CKAN. Gives download stats on package pages, list of most popular packages, etc.
GNU Affero General Public License v3.0
35 stars 81 forks source link

Enabling Google Analytics Breaks the CKAN API #68

Closed Conzar closed 2 years ago

Conzar commented 2 years ago

Enabling Google Analytics on CKAN 2.8 breaks using the CKAN API. Here are the logs

[Tue Jul 19 16:18:00.967516 2022] [wsgi:error] [pid 5736:tid 140046066464512] [remote 127.0.0.1:58312] 2022-07-19 16:18:00,967 INFO  [ckan.lib.base]  /api/3/action/package_show render time 0.072 seconds
[Tue Jul 19 16:18:01.019323 2022] [wsgi:error] [pid 5735:tid 140046066464512] [remote 127.0.0.1:58318] 2022-07-19 16:18:01,019 DEBUG [ckanext.googleanalytics] Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.020749 2022] [wsgi:error] [pid 5735:tid 140046066464512] [remote 127.0.0.1:58318] 2022-07-19 16:18:01,020 INFO  [ckan.controllers.api] Bad Action API request data: Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.021251 2022] [wsgi:error] [pid 5735:tid 140046066464512] [remote 127.0.0.1:58318] 2022-07-19 16:18:01,021 INFO  [ckan.lib.base]  /api/3/action/resource_delete render time 0.006 seconds
[Tue Jul 19 16:18:01.054942 2022] [wsgi:error] [pid 5736:tid 140045948966656] [remote 127.0.0.1:58320] 2022-07-19 16:18:01,054 DEBUG [ckanext.googleanalytics] Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.056197 2022] [wsgi:error] [pid 5736:tid 140045948966656] [remote 127.0.0.1:58320] 2022-07-19 16:18:01,056 INFO  [ckan.controllers.api] Bad Action API request data: Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.056583 2022] [wsgi:error] [pid 5736:tid 140045948966656] [remote 127.0.0.1:58320] 2022-07-19 16:18:01,056 INFO  [ckan.lib.base]  /api/3/action/resource_delete render time 0.005 seconds
[Tue Jul 19 16:18:01.091801 2022] [wsgi:error] [pid 5735:tid 140045948966656] [remote 127.0.0.1:58322] 2022-07-19 16:18:01,091 DEBUG [ckanext.googleanalytics] Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.093187 2022] [wsgi:error] [pid 5735:tid 140045948966656] [remote 127.0.0.1:58322] 2022-07-19 16:18:01,093 INFO  [ckan.controllers.api] Bad Action API request data: Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.093598 2022] [wsgi:error] [pid 5735:tid 140045948966656] [remote 127.0.0.1:58322] 2022-07-19 16:18:01,093 INFO  [ckan.lib.base]  /api/3/action/resource_delete render time 0.006 seconds
[Tue Jul 19 16:18:01.127201 2022] [wsgi:error] [pid 5735:tid 140046066464512] [remote 127.0.0.1:58324] 2022-07-19 16:18:01,127 DEBUG [ckanext.googleanalytics] Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.128604 2022] [wsgi:error] [pid 5735:tid 140046066464512] [remote 127.0.0.1:58324] 2022-07-19 16:18:01,128 INFO  [ckan.controllers.api] Bad Action API request data: Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'id=ID'
[Tue Jul 19 16:18:01.129115 2022] [wsgi:error] [pid 5735:tid 140046066464512] [remote 127.0.0.1:58324] 2022-07-19 16:18:01,129 INFO  [ckan.lib.base]  /api/3/action/dataset_purge render time 0.007 seconds
[Tue Jul 19 16:18:01.161557 2022] [wsgi:error] [pid 5736:tid 140046066464512] [remote 127.0.0.1:58326] 2022-07-19 16:18:01,161 DEBUG [ckanext.googleanalytics] Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'name=Multiple_crops_suitability_and_yield&title=Multiple crops suitability & yield'
[Tue Jul 19 16:18:01.162822 2022] [wsgi:error] [pid 5736:tid 140046066464512] [remote 127.0.0.1:58326] 2022-07-19 16:18:01,162 INFO  [ckan.controllers.api] Bad Action API request data: Error decoding JSON data. Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',) JSON data extracted from the request: 'name=Multiple_crops_suitability_and_yield&title=Multiple crops suitability & yield'
[Tue Jul 19 16:18:01.163270 2022] [wsgi:error] [pid 5736:tid 140046066464512] [remote 127.0.0.1:58326] 2022-07-19 16:18:01,163 INFO  [ckan.lib.base]  /api/3/action/package_create render time 0.006 seconds

Any ideas?

Conzar commented 2 years ago

I am using java to upload to CKAN.

I am also using x-www-form-urlencoded for the content-type. This works without issue when Google Analytics is off but doesn't when it is enabled. I tried with CURL and by default CURL uses x-www-form-urlencoded and that works.

So still trying to figure out why it is failing...

smotornyuk commented 2 years ago

Can you try application/json or multipart/form-data content-types instead? I remember that CKAN 2.8 had some problems with x-www-form-urlencoded requests to the API.

BTW, what exact version of CKAN and ckanext-googleanalytics you are using?

Conzar commented 2 years ago

You are correct! Switching to application/json worked!