Import data API for Google Clouds Vertex AI Datasets is returning an unexpected error

168 views Asked by At

The following returns a 404 error. The requested URL /v1/projects/{my-project-id}/locations/us-central1/datasets/{mydatasetid}:importData was not found on this server. That’s all we know.

This seems like an issue with google. I've adapted the code from the following documentation:

https://cloud.google.com/vertex-ai/docs/image-data/classification/create-dataset#single-label-classification


    $project_id = ''; //filled in with my project_id  
 
    $location = 'us-central1';   

    $yourdatasetid = ""; //filled in with my dataset id

    $authToken = '';  //filled in with my auth token

    $endpoint = "https://us-central1-aiplatform.googleapis.com/v1/projects/$project_id/locations/$location/datasets/" . $yourdatasetid . ":importData";

 
    $data = [
        "inputConfig" => [
            "gcsSource" => [
               "uris" => ["gs://mybucketname/userid/labels.csv"]
           ],
        "import_schema_uri" => "gs://google-cloud-aiplatform/schema/dataset/ioformat/image_classification_single_label_io_format_1.0.0.yaml"
       ]
   ];

    print json_encode($data);
    exit;

    $headers = [
        "Authorization: Bearer $authToken",
        "Content-Type: application/json"
    ];

    $ch = curl_init($endpoint);
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
 
 
    $response = curl_exec($ch);
     print $response;

I've tried running it in command line curl, changing the references, everything. I've seen the endpoint look different in older documentation. I believe this is what they are migrating too with vertex, but the endpoint they provide in this documentation seems to not be working.

1

There are 1 answers

0
Poala Astrid On

A 404 error typically indicates that the URL you are trying to access does not exist on the server. The URL /v1/projects/{my-project-id}/locations/us-central1/datasets/{mydatasetid}:importData suggests that there might be an issue with the URL or the resource you are trying to access. And as per @Siddharth Seth, importData must be switched from import as it was indicating the error.

Posting this answer as a Community Wiki since the OP confirmed that this workaround fixed the issue, and for the benefit of the community that might encounter this use case in the future.