cancel
Showing results for 
Search instead for 
Did you mean: 

Paxata project creation with available dataset through a Java Program

Highlighted
Linear Actuator
Hi,
Can someone please let me know if it is possible to create a project in paxata which will pull the existing dataset information in it through a Java code.
Currently, I was able to create a blank project in paxata using java code. But my requirement is, while project creation it should also pull the existing dataset information in it.

Regards,
Abhijeet
Labels (1)
0 Kudos
19 Replies
Highlighted
DC Motor
Hello Abhijeet, you can create a project in paxata which will use a dataset through a Java code. This is possible by leveraging our REST API Capabilities. Try using our GET feature to retrieve the JSON of the project and then you can loop through the JSON file to update the dataset ID (PUT). Please do let me know if this works for you.

Thank You and Best Regards,
Akshay
0 Kudos
Highlighted
Linear Actuator
Hi Akshay,
Thanks for the answer. Does this mean we have to create a blank project first and then update the same project with already existing dataset?

Regards,
Abhijeet
0 Kudos
Highlighted
DC Motor
Yes create an empty project, retrieve the JSON of that project and the modify the dataset ID. I hope this helps.

Regards,
Akshay
0 Kudos
Highlighted
Linear Actuator
Thanks Akshay. I was able to retrieve single or all project details as json output. But here the drawback is, to retrieve single project details, I had to pass the projectId field. Can we return single project details using project name instead of projectId. If yes then will be thankful if you can share the format for the GET request with project name.
0 Kudos
Highlighted
Linear Actuator
Hi Abhijeet,
we do allow, within the same tenant, identical Project names. Please see below the GET request format and options. The optional "name" argument can be used to return the metadata for all Projects that share the same name. 
Hope this helps.

HTTP GET

URL format: /projects[/projectId][?name=name][&description=description][&userId=userId]

Returns the project metadata for all projects visible to the authenticated user. If the URL contains the optional projectId argument, then the API returns only the metadata for that project.


0 Kudos
Highlighted
Linear Actuator
Hi Melanie,
I do not want to pass projectId field at all (which is required field as per the screenshot you shared).

Can I pass only project name and skip projectId all-together and retrieve the project JSON.


Hi Akshay/Melanie,
I retrieved project JSON as below.

Project Json {"tenantName":"Development","created":"2019-10-31 09:08:42 EDT","permittedActions":["CreateVersion","Share","Know","Publish","Delete","Read","Update"],"tenantId":"1234567","name":"Project25","description":"Created through the REST API","userName":"TestUser","projectId":"abcdefgh","userId":"f99a9471cf374fcbb493053f5ff380e2","updated":"2019-10-31 09:08:42 EDT"}

It does not contain datasetId field and value.
So I added a key value pair for datasetId and modified JSON is as below

Project Json modified {"tenantName":"Development","created":"2019-10-31 09:08:42 EDT","permittedActions":["CreateVersion","Share","Know","Publish","Delete","Read","Update"],"tenantId":"1234567","name":"Project25","description":"Created through the REST API","datasetId":"52b861ea954c48de861e652779885a50","userName":"TestUser","projectId":"abcdefgh","userId":"f99a9471cf374fcbb493053f5ff380e2","updated":"2019-10-31 09:08:42 EDT"} 

Please let me know if this is the correct process and how shall, I execute a PUT call for project with JSON object as input parameter.


Regards,
Abhijeet
0 Kudos
Highlighted
Linear Actuator
Hi again Abhijeet, 
first off my apologies as I mis-spoke about allowing i
dentical Project names within the same tenant That is not accurate. We allow identical dataset names within the same tenant.
However, the GET method I provided above is accurate.

Regarding your most recent question, yes, you can 
write a helper function to do that using our API. If you need assistance creating the help function, please contact the Paxata Customer Success team for help. 
Hope this helps!
0 Kudos
Highlighted
Linear Actuator
Hi Melanie,
Thanks for your reply.
1) GET method syntax you provided is working for us but when I remove projectId and specify only project name it does not work.
e.g. as below. Project25 is the name of the project.
String url = "https://paxata-dev-vip.nam.nsroot.net:8089/rest/projects?Project25

I am expecting a syntax (if available) which will give me project metadata by passing project name only.

2) I will contact Paxata Customer Success team for helper function.
Please provide us the email id of the same team.

Regards,
Abhijeet
0 Kudos
Highlighted
Linear Actuator
HI there, you can reach our CS group through this email: servicedesk@paxata.com
And they can assist you with both of the questions you have above. 
cheers, Melanie
0 Kudos
Highlighted
Linear Actuator
Thanks Melanie.

I have one more query.
As per the documentation of paxata, GET calls for REST token are not supported. So while doing POST call through Java code, are we supposed to create new token every time?

Also, syntax for token generation is as below
curl -sS -f -u "superuser:superuser" "http://localhost:8080/rest/tokens" -X POST

I believe superuser:superuser means userid:password for paxata system for a user.
So, i provided my paxata url credentials there and it did not generate a new token. 
I had to provide old token at the place of superuser:superuser.
Can you please guide.


Regards,
Abhijeet
0 Kudos
Highlighted
DC Motor
curl -sS -f -u ":token" "http://localhost:8080/rest/tokens" -X POST 

this is the syntax when you prefer to use a token. I hope this helps!

Thank You,
Akshay
0 Kudos
Highlighted
Linear Actuator
Hi Akshay,
I understood the syntax and was able to figure it out earlier as well. But to generate a new token, we first need to be aware of previous token. But as per documentation, GET calls to retrieve token are not supported. So, are we supposed to save the token somewhere in database and retrieve from there or paxata internally stores token in some internal table. Can you please guide.


Regards,
Abhijeet
0 Kudos
Highlighted
Linear Actuator
@abhijeetmkhambe

Yes, you need to remember your REST API Token. 

Your best approach to obtaining a Token is to use a PUT:  
  • The server first deletes any existing authentication tokens for the current user, if such tokens exist. 

  • The server creates a new token, and returns the new token as the result.

Thanks,
Bill
0 Kudos
Highlighted
Linear Actuator
@bstephens  
Thanks.

One more query if someone can answer.

The way we can get single or all project details using REST API, is there any REST API which can list a single dataset as well as all datasets currently created in the system?

Regards,
Abhijeet

0 Kudos
Highlighted
Linear Actuator
@abhijeetmkhambe

It's unclear what you mean by "get details" or "list a dataset" I'm answering based on the assumption that you're obtaining metadata about Projects ad Datafiles:

Library Datafile metadata: use the /library/data API
      Response source.type will inform you of the file type
  • File = Imported via local upload
  • Connector: Imported from a Connector
  • Script: An AnswerSet generated from a Paxata Project
FYI: If you want a simple result set of tab separated fields containing a subset of fields, use the "return" option. Here, I get one delimited row of results per dataset containing only the 5 specified fields. 
Thanks,
Bill

0 Kudos
Highlighted
Linear Actuator
@bstephens,
Thanks for the answer. But, if we execute above urls through httpclient, we will get an httpresponse as output. Can paxata return me the metadata of all datasets in json format as output.
0 Kudos
Highlighted
Linear Actuator
@bstephens
Thanks. we are able to retrieve all datasets programmatically using the api syntax you provided.

One more query we have ---> We want to fulfill a scenario where rather than creating a new dataset every time when we fire a query through my java code, we just want to update the dataset version. Is it achievable?

Regards,
Abhijeet
0 Kudos
Highlighted
Linear Actuator
@abhijeetmkhambe

To create a new version of an existing dataset, you'll perform a PUT against the /datasource/imports/ Endpoint. 

New version of dataset using Local Upload: 
New version of dataset uploaded using a configured datasource:
  • https://example.paxata.com/rest/datasource/imports/<dataSourceID>/<datafileId>
Thanks,
Bill
0 Kudos
Highlighted
Linear Actuator
@bstephens
Thanks. I will try with the syntax you provided.

Regards,
Abhijeet
0 Kudos