I am trying to load a simple file through a loading Job to TigerGraph cloud and getting an error like below.
conn = tg.TigerGraphConnection(host=hostName, graphname="MyGraphCopy", username=userName, password=password, apiToken=token)
result = conn.gsql("""
USE GRAPH MyGraphCopy
BEGIN
CREATE LOADING JOB load_persons FOR GRAPH MyGraphCopy {
DEFINE FILENAME MyDataSource;
LOAD MyDataSource TO VERTEX Person VALUES($5, $1, $2, $3, $4) USING SEPARATOR=",", HEADER="true", EOL="\n", QUOTE="double";
}
END
""")
print(result)
Using graph 'MyGraphCopy'
Successfully created loading jobs: [load_persons].
results = conn.gsql("""
USE GRAPH MyGraphCopy
SHOW JOB load_persons
""")
print(results)
Using graph 'MyGraphCopy'
- CREATE LOADING JOB load_persons FOR GRAPH MyGraphCopy {
DEFINE FILENAME MyDataSource;
LOAD MyDataSource TO VERTEX Person VALUES($5, $1, $2, $3, $4) USING SEPARATOR=",",
HEADER="true", EOL="
", QUOTE="double";
}
persons_file = './data/MyGraph_Person.csv'
line_no = 0
with open(persons_file, 'r') as f:
for line in f:
line_no += 1
print(line[:-1])
if line_no >= 5:
break
id,name,email,username,created_at,v_id
1,Marvin Geistmann,mgeistmann0@accuweather.com,mgeistmann0,2018-09-30 07:31:34,1
10,Mead Amberger,mamberger9@sun.com,mamberger9,2019-11-18 23:58:17,10
100,Wendeline Sherar,wsherar2r@kickstarter.com,wsherar2r,2018-09-30 17:27:25,100
11,Vaughan Gerrans,vgerransa@shutterfly.com,vgerransa,2019-04-24 19:33:22,11
results = conn.uploadFile(persons_file, fileTag='MyDataSource', jobName='load_persons')
print(json.dumps(results, indent=2))
HTTPError: 401 Client Error: Unauthorized for url:
https://<my_domain>.i.tgcloud.io:9000/ddl/MyGraphCopy?tag=load_persons&filename=MyDataSource
Not sure what I am not doing right here. Any help is much appreciated.