Jump to content
Changes to the Jaspersoft community edition download ×

How to create a new Domain via REST v2?


jlongoria

Recommended Posts

How can I create a domain using REST v2? (NOTE: I am not allowed to use the PHP client interface.)

I am currently using the python 'requests' library to make the POST request outlined in the reponse found here:

http://community.jaspersoft.com/questions/1011556/create-domain-rest

But I can't get it to work. Can anyone give me a detailed example in which you successfully create a new domain through the REST v2 API?

Here is what I have tried. The desired name of the domain is "myNewDomain". Using 'superuser' authorization.

        url = "http://{{myJasperServer}}/jasperserver-pro/rest_v2/resources/organizations/organization_1/api_test/myNewDomain"
 
        payload = """
                  ------myBoundaryName
                  Content-Type: application/repository.semanticLayerDataSource+json; charset=UTF-8
                  Content-Disposition: form-data; name="resource"
 
                  {
                        "uri" : "/organizations/organization_1/api_test/myNewDomain",
                        "dataSource": {
                            "dataSourceReference": {
                                "uri": "/path/to/myDataSource"
                            }
                        },
                        "schema": {
                            "schemaFile": {
                                "label": "schema",
                                "description": "schema",
                                "type": "xml"
                            }
                        },
                        "label": "myNewDomain"
                     }
 
                  ------myBoundaryName
                  Content-Disposition: form-data; name="schema"; filename="schema.xml"
                  Content-Type: application/xml; charset=UTF-8
 
                 {{ ...contents of schema... }}
                  ------myBoundaryName--
                  """
 
        headers = {
            'authorization': {{ ...auth info... }},
            'accept': "application/json",
            'content-type': "multipart/form-data; boundary=----myBoundaryName",
            }
 
        response = requests.request("POST", url, data=payload, headers=headers)
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...