New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uploading an entity with a select and multi-select attribute #3
Comments
@tanner-ducharme the correct format for thesauri items would be:
When working with the API directly, when in doubt use your browser console to inspect a POST request, you'll get all the proper formats. |
A couple of things:
and got the same error as above
What url should I be using in order to inspect the failed POST? Thanks for your help. |
|
|
I can't really help you debug this without more debugging info such as an specific error or server response.
In you initial error reporting it displays |
The problem is, I have no idea where the string Thanks |
Ok. We are starting to make sense now, you were sending the wrong id and Uwazi wouldn't pass validation. You can get the whole list in JSON format from http://host/api/thesauris |
Thanks, I found it. Thanks |
You'll find template definitions here: https://host/api/templates The actual format of the value you need to send may vary depending on the type of data but it is always an array with objects. The object properties differ. Ie:
The browser request comes handy in case you don't know the format. |
Sorry, I wasn't clear. How can I retrieve the value's for the different thesauri options via the API as opposed to having to look in my browser at https://ral.uwazi.io/api/thesauris? For example, say I wanted to upload a new entity with a 'Source' field value of "Global Times". Is there any way to retrieve it's id code (988283e0-e9a6-45d5-8334-50f4b43b89de) programatically? I hope this makes sense. Thanks again |
@tanner-ducharme yes there is. You send a request to that URL from your code and you parse the response as JSON. This library has some functionality already built-in here: https://github.com/huridocs/python_uwazi_API/blob/main/uwazi_api/Thesauris.py as explained by the end of the readme: https://github.com/huridocs/python_uwazi_API |
whenever I try to pass a string as the value for a select or multi-select field, I get an error reading:
Error uploading entity 422 {"error":"validation failed","validations":[{"keyword":"metadataMatchesTemplateProperties","schemaPath":"#/metadataMatchesTemplateProperties","params":{"keyword":"metadataMatchesTemplateProperties"},"dataPath":".metadata['source']","message":"related dictionary value/s does not exists"
However, I checked the dictionary for the field, and the value I was trying to upload was present in the dictionary.
For reference, I was trying to upload an entity of the type "Media Articles"
The field in question was "Source"
I was trying to upload a "Source" value of "Free Tibet", which is present in the source dictionary according to the "Thesauri" section
This is how I'm creating the entity:
If I comment out the "Source" field, the upload is successful.
Any advice would be greatly appreciated. Thanks
@natasha-todi
@pddocs
The text was updated successfully, but these errors were encountered: