Native API

40 views
Skip to first unread message

nansu

unread,
Feb 29, 2016, 8:08:17 PM2/29/16
to Dataverse Users Community
Hi:

I was trying to get meta data of a dataset of Harvard Datavers. However. it always returns with 404. Does anybody can help me out?

Code:

                
                HttpClient httpclient = new DefaultHttpClient();

                String key="this is the key";

                String id="hdl:1902.1/21183";

String serviceURL = "http://dataverse.harvard.edu/api/datasets/"+id+"/versions/3.0/files?key="+key;

HttpResponse response = httpclient.execute(new HttpGet(serviceURL));

String to = "";

int statusCode = response.getStatusLine().getStatusCode();

System.out.println(statusCode);

if (statusCode == 301 || statusCode == 302) {

Header[] hs = response.getHeaders("Location");

for (Header h : hs) {

to = h.getValue();
}

System.out.println("redirect: " + to);

} else {

String string = EntityUtils.toString(response.getEntity());

System.out.println(string);
}

}

Philip Durbin

unread,
Feb 29, 2016, 9:15:00 PM2/29/16
to dataverse...@googlegroups.com
Rather than "hdl:1902.1/21183" or any other "persistent id" you have to use the *database* id of the dataset with the native API, which isn't the easiest to find.

For example, the database id in this example is "10": https://apitest.dataverse.org/api/datasets/10/versions/1.0/files

We recognize that requiring native API users to use a database id of a dataset is an issue and that they would rather use the "persistent id" (often a DOI) when using the "native" API. That's what https://github.com/IQSS/dataverse/issues/1837 is about. (A fix has been proposed at https://github.com/IQSS/dataverse/pull/2893 .)

Unfortunately, it's not easy to figure out the database id of https://dataverse.harvard.edu/dataset.xhtml?persistentId=hdl:1902.1/21183 or any other dataset . I believe that the only way to expose the database id is via the Search API by passing the (undocumented) parameter show_entity_ids=true

I hope this helps. I just left a comment on issue #1837 that you're being affected. You aren't the only one. I hope the workarounds above help for now.

Phil

--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-commu...@googlegroups.com.
To post to this group, send email to dataverse...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dataverse-community/2edd314f-3268-400f-ab3d-2e3c0ec8adbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

nansu

unread,
Mar 1, 2016, 2:15:31 PM3/1/16
to Dataverse Users Community, philip...@harvard.edu
Hi, Philip,

Yes. I grabbed id with search API and It works. Thank you so much.

在 2016年2月29日星期一 UTC-8下午6:15:00,Philip Durbin写道:
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-community+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages