Upserting Edge Attribute with REST Endpoint

Hello,
im trying to add 2 vertices and an edge via rest with the edge having an attribute .
The result should look like this.

Following the documentation from Built-in Endpoints :: Docs

My Payload for the POST request looks like this:

{
    "vertices": {
        "myVertexType": {
            "Source": {}
        }
    },
    "edges": {
        "myVertexType": {
            "Target": {
                "my_edge": {
                    "myOtherVertexType": {
                        "Source": {}
                    }
                }
            }
        }
    }
}

I just dont know where i can define the edge attribute ‘my_attr’ in the payload.
I would appreciate it if someone can help me out here.

Thanks

Hey @Phan, welcome to our community.

Try like this:

    "edges": {
        "source": {
            "source_vertex_id": {
                "my_edge": {
                    "target": {
                        "target_vertex_id": {
                               "my_attr": 23542
                         }
                    }
                }
            }
}

Best,
Bruno

1 Like

Thanks Bruno!!! That syntax works. I got the docs wrong i thought the attribute key nested in the target vertex refers to the target vertex attribute.

Here is the full request body to copy and paste, just in case someone wants to test something similar

{
    "vertices": {
        "myVertexType": {
            "Source": {}
        }
    },
    "edges": {
        "myVertexType": {
            "Source": {
                "my_edge": {
                    "myOtherVertexType": {
                        "Target": {
                               "my_attr":{"value": 23542}
                         }
                    }
                }
            }
}
}
}
1 Like