Import a Dataset into a Dataverse

Skip to first unread message

Uus Khusni

Jun 11, 2019, 3:46:20 AM6/11/19
to Dataverse Dev

I am from Indonesia, and newbie in dataverse. I try to call API dataverse from PHP to import dataset JSON into dataverse but i got messege

{"status":"ERROR","code":404,"message":"'/api/v1/dataverses/puslitekonomi-lipi/:import' endpoint does not exist on this server. Please check your code for typos, or consult our API guide at"}

Please help us, below is my code write on PHP

$url = 'https://xxx/api/dataverses/xxx/:import?pid=xxx&release=no&key=xxx';

//create a new cURL resource
    $ch = curl_init($url);
    //echo $url;
    //HTTP username.
    $username = 'xxx';
//HTTP password.
    $password = 'xxx';
//setup request to send json via POST
    $payload = json_encode($array_dataset);
//attach encoded JSON string to the POST fields

    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

//set the content type to application/json
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: Basic '. base64_encode("$username:$password")));

//return response instead of outputting
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//execute the POST request
    $result = curl_exec($ch);

    echo $result;
    //echo 'Request Error:' . curl_error($ch);
//close cURL resource

Philip Durbin

Jun 11, 2019, 8:57:54 AM6/11/19
Hi Uus,

It's been a while since I've done any PHP but I just asked at I asked at and Jeremy Richard figured out what the problem is, I think.

(You are welcome to join us at of course!)

That "endpoint does not exist on this server" error is easy to trigger. If you go to for example, you will see that error.

The problem seems to be that the "path" in your $url is missing the word "datasets". Instead of...
... you should try something like...

curl -H "X-Dataverse-key: $API_TOKEN" -X POST $SERVER_URL/api/dataverses/$DV_ALIAS/datasets/:import?pid=$PERSISTENT_IDENTIFIER&release=yes --upload-file dataset.json

Finally, have you considered contributing a PHP client library for Dataverse? I would be happy to create a repo at and give you "push" access to it! All of the client libraries listed at have been contributed by the community.



You received this message because you are subscribed to the Google Groups "Dataverse Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

Reply all
Reply to author
0 new messages