Skip to content
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

Added tabulartags in files metadata for files metadata #10027

Merged

Conversation

saikiranpatil
Copy link
Contributor

@saikiranpatil saikiranpatil commented Oct 19, 2023

What this PR does / why we need it:
correcting the API Guide for update Request where TabularTags is required in the Request Header

Which issue(s) this PR closes:

@pdurbin pdurbin added this to Ready for Review ⏩ in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) via automation Oct 19, 2023
@pdurbin pdurbin self-assigned this Oct 19, 2023
@pdurbin pdurbin moved this from Ready for Review ⏩ to In Review 🔎 in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) Oct 19, 2023
@pdurbin pdurbin added the Size: 0.5 A percentage of a sprint. 0.35 hours label Oct 19, 2023
Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saikiranpatil thanks for the PR!

I dug up what I had sent @MellyGray in Slack.

She wrote:

curl -H "X-Dataverse-key:1967e628-3bf4-4bc1-abe9-711f45b9b6b9" -X POST \ -F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","tabularTags":["Survey"],"restrict":false}' \ "http://localhost:8000/api/files/1453/metadata"

And I said, please try dataFileTags instead of tabularTags in your JSON. That’s what I’m seeing here: https://github.com/IQSS/dataverse/blob/v5.14/src/main/java/edu/harvard/iq/dataverse/datasetutility/OptionalFileParams.java#L60

Pretty printed (easier to read), the fixed version looks like this:

{
  "description": "My description bbb.",
  "provFreeform": "Test prov freeform",
  "dataFileTags": [
    "Survey"
  ],
  "restrict": false
}

(For this pull request, it's best to keep it on one line, though.)

Please make sure all JSON is valid and please watch the single quotes.

You can test against https://demo.dataverse.org if you like! If you have questions, please feel free to ask here or open a topic in #dev at https://chat.dataverse.org . Thanks!

"$SERVER_URL/api/files/:persistentId/metadata?persistentId=$PERSISTENT_ID"

The fully expanded example above (without environment variables) looks like this:

.. code-block:: bash

curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X POST \
-F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"restrict":false}' \
-F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"restrict":false}', "dataFileTags":["Survey"]} \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The single quote on the right should be on the outside.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, I should have rechecked before commit. i will correct them

@@ -3108,15 +3108,15 @@ A curl example using an ``ID``
export ID=24

curl -H "X-Dataverse-key:$API_TOKEN" -X POST \
-F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"restrict":false}' \
-F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"restrict":false},"dataFileTags":["Survey"]}' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not parse as valid JSON. Please try it (and the others) at https://jsonlint.com (or your favorite validator):

Screenshot 2023-10-19 at 2 35 26 PM

@saikiranpatil
Copy link
Contributor Author

hey @pdurbin, i have made changes, are there any mistake in that?

@pdurbin
Copy link
Member

pdurbin commented Oct 19, 2023

@saikiranpatil I haven't checked the JSON but overall I think it's looking better. Probably we'll want to keep the "categories" in the JSON because it's different that tabular tags. I can add it back if you want. Please just let me know.

@pdurbin
Copy link
Member

pdurbin commented Oct 19, 2023

@saikiranpatil oh, also, do you want to try testing your curl commands at https://demo.dataverse.org ? To make sure they work?

@saikiranpatil
Copy link
Contributor Author

saikiranpatil commented Oct 20, 2023

@pdurbin I added back "categories", I am not sure how to check commands at https://demo.dataverse.org/, but I checked JSON, it's in correct JSON format.

@pdurbin
Copy link
Member

pdurbin commented Oct 20, 2023

@saikiranpatil to check the curl commands you would open a terminal and execute them. I know you have them in front of you but here's an HTML preview in case you haven't been building the HTML version: https://dataverse-guide--10027.org.readthedocs.build/en/10027/api/native-api.html#updating-file-metadata

The demo server is already used in the example:

curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X POST \
  -F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"dataFileTags":["Survey"],"restrict":false}' \
  "http://demo.dataverse.org/api/files/24/metadata"

To get an API token you would create an account on https://demo.dataverse.org and follow these steps:
https://dataverse-guide--10027.org.readthedocs.build/en/10027/user/account.html#how-to-create-your-api-token

Before running the curl command you'll want to create a dataset, upload a file, and figure out the file id (instead of 24 in the example above). The easiest way is to edit the permissions on the file and look for the file id in the URL.

Does that make sense?

@saikiranpatil
Copy link
Contributor Author

@pdurbin got it. Are there are any changes required in PR?

@pdurbin
Copy link
Member

pdurbin commented Oct 20, 2023

@saikiranpatil I haven't tested it so I'm not sure. Did you test it?

@saikiranpatil
Copy link
Contributor Author

I am totally new to this, I have created account, uploaded file as
image
and used the id as 2102722 from the image,
upon request i got as
image
did I take the ID incorrectly?

@pdurbin
Copy link
Member

pdurbin commented Oct 20, 2023

Huh. From a quick look it seems right. 🤔 Can you please try changing the jsonData? Maybe you could try simplifying it all the way down to just changing the description:

'jsonData={"description":"My description bbb."}'

Another sanity check, using your API token, can you get the metadata for the files? Like this:

curl -H "X-Dataverse-key:xxxxx" https://demo.dataverse.org/api/files/2102722/metadata

You could also try a published file without a key:

curl https://demo.dataverse.org/api/files/2102661/metadata gives me this:

{"label":"ardour.desktop","restricted":false,"id":1897048}

@saikiranpatil
Copy link
Contributor Author

again tried this
image
even this is not working
image

@pdurbin
Copy link
Member

pdurbin commented Oct 20, 2023

Weird. You seem to be using https://reqbin.com/curl

This one works for me:

Screenshot 2023-10-20 at 2 12 26 PM

@saikiranpatil
Copy link
Contributor Author

maybe, it's problem with my way of uploading file.
does the changes made in the documentation works correctly, i am unable to test it.

@pdurbin
Copy link
Member

pdurbin commented Oct 20, 2023

When I get to a good stopping point, I'll play with it. Thanks and have a good weekend!

@saikiranpatil
Copy link
Contributor Author

@pdurbin if the changes made in documentation are working correctly, please merge PR.

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this but it should work. Sending to ready for QA.

IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from In Review 🔎 to Ready for QA ⏩ Oct 23, 2023
@kcondon kcondon self-assigned this Oct 23, 2023
@kcondon kcondon merged commit a8ea920 into IQSS:develop Oct 23, 2023
1 of 2 checks passed
IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from Ready for QA ⏩ to Done 🚀 Oct 23, 2023
@pdurbin pdurbin added the hacktoberfest-accepted Accepted for HF, see https://groups.google.com/g/dataverse-community/c/n_Nn_T2yA-w/m/BcoXO4tEAQAJ label Oct 24, 2023
@pdurbin
Copy link
Member

pdurbin commented Oct 24, 2023

@saikiranpatil merged! Thanks for the pull request! ❤️

@pdurbin pdurbin added this to the 6.1 milestone Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted for HF, see https://groups.google.com/g/dataverse-community/c/n_Nn_T2yA-w/m/BcoXO4tEAQAJ Size: 0.5 A percentage of a sprint. 0.35 hours
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Feature Request: API Guide add docs about how to update tabularTags in the files metadata
3 participants