2

You can create a new project in GoodData using API: http://docs.gooddata.apiary.io/#project

Sometimes, i.e. when creating a project from a template, the project creating isn't synchronous. When I use the project before it's ready I get errors like 403 and 409.

What are the possible states of the project (besides ENABLED)? What is the recommended way to create a project (maybe polling for a certain state)? What are the error statuses and how to handle them? A code sample would be useful.

pcv
  • 2,121
  • 21
  • 25

3 Answers3

2

yes the best way is to poll project state.

project can have these states.

'PREPARING' | 'PREPARED' | 'LOADING' | 'ENABLED' | 'DISABLED' | 'DELETED' | 'ARCHIVED',

I can create example for you, what is your preferred language for it?

Jiri Simon

GoodData support

Jiri Simon
  • 91
  • 2
2

I would suggest you to use ruby cookbook for creating new projects. Gooddata has very good libraries in ruby for handling projects

Creating project with template http://sdk.gooddata.com/gooddata-ruby-examples/#_creating_project_from_template

Creating an empty project http://sdk.gooddata.com/gooddata-ruby-examples/#_creating_empty_project

Ideally , you would want to create a gooddata project using cloud connect etl tool as mentioned in the following link https://help.gooddata.com/cloudconnect/manual/gooddata-project.html

Amogh Huilgol
  • 1,252
  • 3
  • 18
  • 25
1

here you can see really simple example in python.

from urllib2 import Request, urlopen
import Cookie
from json import dumps
import re
import ast



values = dumps({"postUserLogin":{"login":"jiri.simon@gooddata.com","password":"mypassword","remember":1}})
headers = {"Accept": "application/json", "Content-Type": "application/json"}
request = Request("https://na1.secure.gooddata.com/gdc/account/login", data=values, headers=headers)
response_body = urlopen(request)
#print response_body.read()
msg = response_body.info()
#print msg.getheaders('set-cookie')
x=msg.getheaders('set-cookie')
import re
GD_SST = re.search('GDCAuthSST(.*?);', x[1]).group()
print GD_SST


headers = {"Cookie": "$Version=0; $Path=/gdc/account", "Accept": "application/json", "Content-Type": "application/json"}
headers['Cookie'] = GD_SST
request = Request("https://na1.secure.gooddata.com/gdc/account/token", headers=headers)
response_body = urlopen(request)
#print response_body.read() 
#print response_body.info() 
msg = response_body.info()
#print msg.getheaders('set-cookie')
x=msg.getheaders('set-cookie')
#print x
GD_TT = re.search('GDCAuthTT(.*?);', x[0]).group()
print GD_TT


values = dumps({ "project" : {
       "content" : {"guidedNavigation": 1, "driver" : "Pg", "authorizationToken" : "MYTOKEN"},
       "meta" : {
       "title" : "Test Project API",
       "summary" : "Testing Project",
       "projectTemplate" : "/projectTemplates/{templateName}/{version}"
       } }
})
headers = {"Accept": "application/json", "Content-Type": "application/json"}
headers['Cookie'] = GD_TT
request = Request("https://na1.secure.gooddata.com/gdc/projects", data=values, headers=headers)
response_body = urlopen(request).read()
#project_url=response_body['uri']
project_url=ast.literal_eval(response_body)['uri']
print project_url

request = Request("https://na1.secure.gooddata.com%s" % project_url , headers=headers)
#response_body = urlopen(request).read()
#print response_body
response_body = urlopen(request).read()
print response_body
#project_details = ast.literal_eval(response_body)['project']
#project_state = project_details['content']['state']

project_state = " "
#print "project_state is %s" % project_state
while project_state != "ENABLED" or project_state != "DELETED" :

    response_body = urlopen(request).read()
    #print response_body
    project_details = ast.literal_eval(response_body)['project']
    project_state = project_details['content']['state']
    print "project_state is %s" % project_state
    if project_state == "DELETED":
      break

if project_state == "ENABLED" :
  print "project created %s" %project_ur
else:
 print "something was wrong"
Jiri Simon
  • 91
  • 2