Project creation error

50 views
Skip to first unread message

Ahmed Khan

unread,
Mar 16, 2021, 1:20:00 AM3/16/21
to Grafeas Users
Hi,
Is there a working example of Grafeas with python that goes through project, notes and occurances creation. I tried the example from python_client library but it fails. I am running Grafeas 0.1.6 locally as Docker and can curl the endpoint.

-----------------------
from __future__ import print_function
import time
import grafeas
from grafeas.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = grafeas.GrafeasProjectsApi()
#body = grafeas.ApiProject() # ApiProject | The project to create.
body = "demo"

try:
    # Creates a new project.
    api_response = api_instance.create_project(body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling GrafeasProjectsApi->create_project: %s\n" % e)
------------------
It fails with error:
Exception when calling GrafeasProjectsApi->create_project: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Content-Type': 'text/plain; charset=utf-8', 'Vary': 'Origin', 'X-Content-Type-Options': 'nosniff', 'Date': 'Tue, 16 Mar 2021 05:17:25 GMT', 'Content-Length': '10'})
HTTP response body: Not Found

Thanks
AK

Ahmed Khan

unread,
Mar 16, 2021, 1:39:29 AM3/16/21
to Grafeas Users
Some more details, able to create a project with curl command:
curl -k -H "Content-type: application/json" -H "Accept: application/json" -d "{\"name\":\"projects/artifacts\"}"  http://localhost/v1beta1/projects

But the python script still failing:

from __future__ import print_function
import time
import grafeas
from grafeas.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = grafeas.GrafeasProjectsApi()
#body = grafeas.ApiProject() # ApiProject | The project to create.
body = {"name":"projects/artifacts2"}

try:
    # Creates a new project.
    api_response = api_instance.create_project(body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling GrafeasProjectsApi->create_project: %s\n" % e)

Brian Costlow

unread,
Mar 17, 2021, 8:11:52 AM3/17/21
to Grafeas Users
See the thread below: https://groups.google.com/g/grafeas-users/c/vhvHWdWDe_M 

The API of the Python Client and the Server are out of sync. You're getting  a 404 because Python is trying to hit a URL for the v1alpha API but the server is running the v1beta.
There is an open issue, and as soon as I get a couple things off my plate (I do some work on PyCon, and we are in the middle of talk selection), I am going to look at it, unless someone else gets there first.

Ahmed Khan

unread,
Mar 25, 2021, 9:54:39 PM3/25/21
to Grafeas Users
Thanks mate, looking forward to client libraries update
iress.com
Ahmed Khan  
Information Security Architect
ahmed...@iress.com
www.iress.com
Level 16, 385 Bourke Street,
 Melbourne, Victoria, 3000
The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities. ​If you have received this email in error please notify the sender immediately and delete this email. 
nosig
Reply all
Reply to author
Forward
0 new messages