Cannot insert record into Person Vertex graph database

Please am just New to Tigergraph.

Am making Restful API Call to Tiger Graph Cloud to insert record to database.

I have the following vertex schemas for Person Vertex (id primary id(int), age string, name string)

Now I want to insert record into Person Vertex

Here is my json Payload


{
  "vertices": {
    "Person": {
      "id": {

 "age": {
           "value": "30"
         },

        "name": {
           "value": "Ann Ball"
         }
      },
      "id": {

 "age": {
           "value": "23"
         },
        "name": {
           "value": "Tony More"
         }
      }
    }
  }
}

When I make restful Api curl request. it throws error below

{“version”:{“edition”:“enterprise”,“api”:“v2”,“schema”:4},“error”:true,“message”:“Exception in OnStart: stoll”,“code”:“REST-10004”}

Please what am I doing wrong. Is it problem with Vertex Id, I dont even know how to get the json payload to work. Please help me. Thanks

A value for the vertex’s ID needs to be provided as well. Note that because the ID is an int type, the values should be provided without quotes.

For your specific example, I believe it should look like this (though I haven’t tested this):

{"vertices": {
    "Person": {
      10: {
        "age": {
           "value": "30"
         },
         "name": {
           "value": "Ann Ball"
         }
      },
      30: {
        "age": {
           "value": "23"
         },
        "name": {
           "value": "Tony More"
         }
      }
    }
  }
}

You can find an example in our documentation in the below link, at the “Upsert Example Data 1: Two User vertices” code block. I end up referencing this documentation every time I have to write a JSON payload.

2 Likes

Thanks @Elliot_Martin