简体   繁体   中英

Bluemix IBM Graph service - Create vertices

I am trying to create a vertex using the vertices API.

Please take a look at the following snippet.

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()

The curl on the API url is working fine and I received the following response

{
    "requestId":"49646d73-0073-450a-9976-57049821fa42",
    "status":{
        "message":"",
        "code":200,
        "attributes":{}
    },
    "result":{
        "data":["StandardTitanGraph"],
        "meta":{}
    }
 }

and I guess this response is correct.

But the API URLs are giving me the following errors.

raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 502 Server Error: Bad Gateway

As Bill mentioned above this issue has been fixed in the latest release of the service. Please try it again and update this Question.

In order to get the latest update you will need to create a new service https://console.ng.bluemix.net/catalog/services/graph-data-store/ and run your program against.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM