Connect to TigerGraph using JQuery to Create, Read, Update and Delete Nodes and Relationships

32 views
Skip to first unread message

Martyn Bowis

unread,
Feb 25, 2020, 7:35:45 PM2/25/20
to gsql-users
Can you please provide an example of how to use JQuery and AJAX to connect to TigerGraph, and to then create, read, update and delete nodes and relationships?

Example JQuery AJAX:

$( document ).ready(function() {
  var api_url = 'https://api.linkpreview.net'
  var key = '5b578yg9yvi8sogirbvegoiufg9v9g579gviuiub8' // not real

  $( ".content a" ).each(function( index, element ) {

    $.ajax({
        url: api_url + "?key=" + key + " &q=" + $( this ).text(),
        contentType: "application/json",
        dataType: 'json',
        success: function(result){
            console.log(result);
        }
    })
  });
});


Thanks,
Martyn

Xinyu Chang

unread,
Feb 25, 2020, 7:57:50 PM2/25/20
to Martyn Bowis, gsql-users
Please see our built-in APIs on how to update the graph

Thanks.


Xinyu Chang
Director of Customer Solutions
TigerGraph, Inc.


--
Welcome to GSQL-user group.
- our mission is bringing the power of graph databases to everyone www.opengsql.org
- technical resource can be found here https://docs.tigergraph.com/
---
You received this message because you are subscribed to the Google Groups "gsql-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gsql-users+...@opengsql.org.
To view this discussion on the web visit https://groups.google.com/a/opengsql.org/d/msgid/gsql-users/76b383f9-ec89-4455-8802-784e223ac554%40opengsql.org.

Renchu Song

unread,
Feb 25, 2020, 8:18:10 PM2/25/20
to gsql-users

    $.ajax({
      type: 'POST',
      url: "http://tigergraph-ip:9000/graph/MyGraph",
      data: {
        "vertices": {
          "Categories": {
            "some category": {
              "CategoryID": {
                "value": 1
              },
              "CategoryName": {
                "value": "some category"
              }
            }
          }
        }
      },
      dataType: "json",
      headers: {
        'Authorization' : 'Bearer your-token-here'
      }
    }).done(function(data) {
      // your logic to handle with data
    });

Martyn Bowis

unread,
Feb 25, 2020, 9:09:45 PM2/25/20
to gsql-users
What would the your-token-here value be?  Where would I find that please?

When I try the above using the pwd for my tg database, I get the following type of error:

Access to XMLHttpRequest at 'http://mygraph.i.tgcloud.io:9000/graph/MyDatabase' from origin 'http://mydomain.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.


Jonathan Herke

unread,
Feb 26, 2020, 10:12:38 AM2/26/20
to Martyn Bowis, gsql-users
STEPS (Open your cloud instance)
1. Click "Admin" (top right)
2. Click "User Management" (on left)
3. Click "Create" (button)
4. Click "Copy Secret"
5. Open a Terminal
6. Paste token request command
7. Add a Server
8. Add a Secret

sample request to grab token:

curl -X GET 'localhost:9000/requesttoken?secret=jiokmfqqfu2f95qs6ug85o89rpkneib3&lifetime=1000000'



image.png

Jon Herke
Developer/Technical Evangelist, TigerGraph



--
Welcome to GSQL-user group.
- our mission is bringing the power of graph databases to everyone www.opengsql.org
- technical resource can be found here https://docs.tigergraph.com/
---
You received this message because you are subscribed to the Google Groups "gsql-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gsql-users+...@opengsql.org.
Reply all
Reply to author
Forward
0 new messages