OpenDevelopmentMekong / wpckan

wpckan is a wordpress plugin that exposes a series of functionalities to bring content stored in CKAN to Wordpress' UI and also provide mechanisms for archiving content generated on Wordpress into a CKAN instance.
GNU General Public License v3.0
22 stars 14 forks source link

API error, not accepting marc21_110 #371

Open jokke opened 4 years ago

jokke commented 4 years ago

We have been using the API to create data sets. We used to be able to set the author's organisation using the marc21_110 field. However, now the server throws an error:

Trying to sync a record with the organization set to UNDP, but your system does not accept it. The error is "error": {"marc21_110": ["Failed to decode JSON string"], "__type": "Validation Error"}}

Can you please advise?

arky commented 4 years ago

@jokke Here are some comments from @gtkChop on Gitter.

"Looks like something wrong with the json syntax If I get the data for creating a dataset then, I can debug on this. marc21_110 - is just a fluent_text field. May be non utf-8 character. Not sure, need to have a look at the data to figure out where the error is.

Also need to give content type as utf-8 if thats missing."

@gtkChop Could you please help debug this issue. Thanks!

ss-bhat commented 4 years ago

@jokke Could you please send me the JSON data that you are using to create a dataset? Thanks

jokke commented 4 years ago

Yes it is UTF8, in fact only ASCII characters are used for this particular example. The JSON is as follows:

{"odm_copyright":"To be determined","metadata_modified":"2020-01-12T00:19:47","version":"1.0","author_email":"laofab.repo@gmail.com","marc21_110":"UNDP","maintainer":"LaoFAB","odm_spatial_range":["la"],"odm_keywords":"HDI, poverty, inequality, Country Data, Gender & Ethnicity, General Economic Development, Poverty","author":"LaoFAB","name":"laofab-2373-1","marc21_260c":"2013","license_title":"License unspecified","title":"Lao PDR - Explanatory Notes for the 2013 Human Development Report","maintainer_email":"laofab.repo@gmail.com","odm_language":["English"],"document_type":"reports_journal_articles_and_research_papers","metadata_created":"2020-01-12T00:19:47","license_id":"unspecified","title_translated":{"en":"Lao PDR - Explanatory Notes for the 2013 Human Development Report"},"url":"http://www.laofab.org/document/view/2373","owner_org":"laofab","taxonomy":["Censuses"],"type":"library_record"}

jokke commented 4 years ago

Response code is 409 and response data:

{"help": "https://data.opendevelopmentmekong.net/api/3/action/help_show?name=package_create", "success": false, "error": {"marc21_110": ["Failed to decode JSON string"], "__type": "Validation Error"}}

jokke commented 4 years ago

@gtkChop any ideas around this?

arky commented 4 years ago

@gtkChop Any solution for this issue? Really appreciate any workaround so @jokke could not be blocked by this error. Thanks!

ss-bhat commented 4 years ago

@arky @jokke

Please see below changes to be made in the JSON data.

Once you make the necessary changes to the above field record creation should be successful. Thanks

Please let me know if you encounter any issues. Thanks

jokke commented 4 years ago

Thanks for looking into this.

The format of the marc21_110 must be a recent change as the syntax I showed has been working. How do you announce these changes?

Regarding the owner_org, I think this was a typo, it should have been 'laofab-organization'. However, my user is not allowed to set this: "Access denied: User joakim not authorized to add dataset to this organization". Any ideas on how to overcome this?

ss-bhat commented 4 years ago

@jokke Yeah, marc21_110 has been made multilingual. Hence language tag is required.

Announcing the change, I am not sure about how this is done. I think @prustar or @arky might be able to help you with this.

Access Denied: This happens when the user tries to update/create a package to the organization which the user doesn't have access to.

Organization admin can add a user to the organization with suitable rights (member, editor or admin). Go to page /organization (select your organization) -> Manage -> Members -> add user.

Hope this helps. Thanks

jokke commented 4 years ago

Thanks for the pointer @gtkChop . I can see that my user ("joakim") is a member of the LaoFAB organization with the role "admin". So I am not sure why I am not authorized to add datasets.... Any idea?

ss-bhat commented 4 years ago

@jokke are you passing the credentials along with the request.

It is recommended to pass a request along with API-KEY as credentials.

Please see the CKAN docs for the reference: https://docs.ckan.org/en/ckan-2.7.3/api/

Thanks

jokke commented 4 years ago

@gtkChop I am using the API-KEY, not username/password.

ss-bhat commented 4 years ago

Could you please give me an organization URL and your username? Thanks. @jokke

jokke commented 4 years ago

URL: https://data.opendevelopmentmekong.net/organization/laofab username: joakim

Thanks!

arky commented 4 years ago

Announcing the change, I am not sure about how this is done. I think @prustar or @arky might be able to help you with this.

The OD wiki pages are the best way to communicate these changes. At the moment these technical pages are being updated with the latest changes.

Access Denied: This happens when the user tries to update/create a package to the organization which the user doesn't have access to.

Organization admin can add a user to the organization with suitable rights (member, editor or admin). Go to page /organization (select your organization) -> Manage -> Members -> add user.

Hope this helps. Thanks

jokke commented 4 years ago

@gtkChop any news around this?

arky commented 4 years ago

@gtkChop This bug has been open for a month now. Is there a solution or workaround so @jokke could continue contributing. Please advice as soon as possible. Thanks!

arky commented 4 years ago

@gtkChop Can you please take a look at this issue and help resolve this quickly. Thanks!

// CC @jokke

ss-bhat commented 4 years ago

@arky @jokke

I can see your username in the organization as admin. In that case, you should be able to add a dataset, I believe there is some mismatch in organization name that you are using. Please below organization detail (type using organization ID).

owner_org: laofab (or 137ee03a-0c95-489d-842a-ee14c137b132)

Use your API-KEY. If you forgot this, you can regenerate the API key using the user Interface.

If you still face any issue. Please drop an email with your script to swaroop@derilinx.com (please remove your sensitive information from the script). I will have a look and would be easy to debug. Thanks

arky commented 4 years ago

Thanks @gtkChop for looking this.

@jokke Please CC me in your email so I can help you with debugging as well.