Error: "'id' is not found in the VERTEX parameter 'me'."

Hey guys, getting error when I run this query. It compiles and installs. Just trying to insert an edge between 2 vertices. My original version of this query required ids as strings and it worked. However the query would timeout if the user id was not found. So here is the new version but it gives me an error.

Any help would be appreciated. Here is my query:


CREATE QUERY addContact(VERTEX<User> me, VERTEX<User> friend) FOR GRAPH Social SYNTAX V2{
  IF (me != friend) THEN
    INSERT INTO contact_of (FROM, TO) VALUES (me, friend);
    PRINT true AS data;
  ELSE
    PRINT false AS data;
  END;
}

UPDATE: I ran the query in interactive mode and it worked so I looked at how I was calling it. I am using POST running the following javascript code in nodejs:

let response = await fetch(
    requestUrl, 
    { 
        method: 'POST',
        // Tigergraph expects JSON string that has an encoded URI 
        body: encodeURI(JSON.stringify({me:343243255, friend: 465694395}),
        headers: {
                    "Content-Type": "application/json",
                    "Authorization": `Bearer ${process.env.TIGERGRAPH_TOKEN}`,
                    "Accept":"application/json"
                }
    }
)

I tried taking out encodeURI and I still got the same error. Finally I switched to using GET with a query string and it finally worked. Does anyone know why using POST is not working?

This thread may be helpful to you

2 Likes

Thx markmegerian. That was very helpful!

2 Likes