Stream: troubleshooting

Topic: Import json files containing customized metadata block


view this post on Zulip Hansen Zhang (Aug 29 2024 at 15:07):

Hi Everyone, I added a customized metadata block and can add metadata to the new fields at the front end, but failed to import Json files containing the customized metadata. It seems the new block need to be added to ImportDDIServiceBean.java and ImportGenericServiceBean.java to make the API work. Is it the right way to do it? Are there easier solutions? Thanks!

view this post on Zulip Philip Durbin ๐Ÿš€ (Sep 03 2024 at 17:51):

Huh. It should work! Here's what I'd suggest...

view this post on Zulip Philip Durbin ๐Ÿš€ (Sep 03 2024 at 17:51):

Of course, you might be talking about importing a new dataset rather than importing. But I'd start with creating first to make sure it's working.

view this post on Zulip Hansen Zhang (Sep 03 2024 at 18:14):

Hi Philip, Thanks for your great recommendations. I will give it a try. One thing I want to mention is that I decompiled and looked at the import class file after adding the custom metadata block, but did not see any of the custom metadata fields. Is that what it supposed to be?

view this post on Zulip Philip Durbin ๐Ÿš€ (Sep 03 2024 at 18:47):

Well, it should all be written generically. I wouldn't expect you to see specific fields in the decompiled output.

view this post on Zulip Sherry Lake (Sep 03 2024 at 19:16):

We have a custom metadata block and have been creating datasets with the customization fields via API. I have not touched any of the "ServiceBean" files.

To set up our custom metadata block we followed the instructions here:
https://guides.dataverse.org/en/latest/admin/metadatacustomization.html

Once you have created a ".tsv" file (properly formatted), then you 1) enable the metadata block, 2) update the Solr schema with the "update-fields.sh" script, 3) reload your Solr schema.

If you can add metadata via the UI, then seems you have done the above steps.

I would do what @Philip Durbin suggests above -
I would export the dataset you created via the UI to see how the json is rendered and use that json as an example to create a new dataset via the API.

curl "$SERVER/api/datasets/export?exporter=dataverse_json&persistentId=doi:$DOI"

view this post on Zulip Hansen Zhang (Sep 03 2024 at 19:22):

I just tried with an exported Json containing the metadata block. It seems the import worked with this message: {"status":"OK","data":{"id":17,"persistentId":"doi:10.5072/FK2/VRXQQ2"}}. But the dataset does not show up in the app. I did the import again and it says the dataset already exists.

view this post on Zulip Sherry Lake (Sep 03 2024 at 19:30):

If the dataset exists, it should just make a "draft", right @Philip Durbin
@Hansen Zhang if you go to the dataset, in the UI, do you see other versions? Click the "Versions" tab. You should see something like this:
Screenshot-2024-09-03-at-3.29.42PM.png

view this post on Zulip Sherry Lake (Sep 03 2024 at 19:31):

Also who "owns" the dataset? If you are not logged in (and it was your token that created the dataset), you will not be able to see the dataset - until it is published.

view this post on Zulip Hansen Zhang (Sep 03 2024 at 19:34):

I am doing it in a development environment. The imported dataset did not show up at all, although status was OK.

view this post on Zulip Hansen Zhang (Sep 03 2024 at 19:35):

I am doing it as the Admin and I logged in.

view this post on Zulip Hansen Zhang (Sep 03 2024 at 19:49):

Hi Philip and Sherry, I tried to upload the exported Json file to Dataverse in production. It worked. I have no idea what's wrong with my local installation. Thank you for your help!

view this post on Zulip Philip Durbin ๐Ÿš€ (Sep 03 2024 at 19:57):

Oh, great! I'm glad it worked in prod.


Last updated: Oct 30 2025 at 06:21 UTC