我正在尝试使用顶点API创建一个顶点。
请看下面的片段。
def create_vertex(self,creds,id):
creds = json.load(open(creds))
print(creds)
url = creds['credentials']['apiURL'] + '/vertices'
start = time.time()
res = requests.post(
url,
auth=(
creds['credentials']['username'],
creds['credentials']['password']
),
data=json.dumps([{"id":"256"}]),
headers={"Content-Type": "application/json"}
)
res.raise_for_status()
print 'query took %s seconds' % (time.time() - start)
return res.json()
API url上的curl工作正常,我收到了以下响应
{
"requestId":"49646d73-0073-450a-9976-57049821fa42",
"status":{
"message":"",
"code":200,
"attributes":{}
},
"result":{
"data":["StandardTitanGraph"],
"meta":{}
}
}
我想这个回答是正确的。
但是API URL给了我以下错误。
引发HTTPError(http_error_msg,response=self)requests.exceptions.HTTPError:502服务器错误:错误的网关
如上所述,此问题已在最新版本的服务中修复。请重试并更新此问题。
为了获得最新更新,您需要创建一个新服务https://console.ng.bluemix.net/catalog/services/graph-data-store/并运行您的程序。