Jump to content
We've recently updated our Privacy Statement, available here ×

Create Domain via Rest


t.mehner

Recommended Posts

I am trying to create a Domain via Rest. Under Rest v1 it is said, that one hase to create a multipartrequest to solve this problem.
Well, i am not perfectly sure how to do this. 

I am so far:

http://ata:80/jasperserver-pro/rest_v2/resources/organizations/MyDomains?createFolders=false&q=MyDomain&type=semanticLayerDataSource
But how can i add the schema.xml?
My sourcedescription is the following:

{
    "schema": {
        "schemaFile": {
            "type": "xml",
            "label": "MyDomain_schema"
        }
    },
    "dataSource": {
        "dataSourceReference": {
            "uri": "/organizations/MyDataSources/jdbsDataSource"
        }
    },
    "label": "MyDomain"
}.

How can i construct a falid multipartrequest? An example would be the best. Thank you
Link to comment
Share on other sites

  • 3 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

It took me _forever_ to figure this out. I abandoned all hope with the v1 REST route when none of the examples I found worked, including one sent to me by Jaspersoft support. Then on to v2! The docs are sorely lacking. This was the magic sauce to get it to finally work:

 

Important points:

 

- Use POST /rest_v2/resources/path/to/domain

- Request content type "multipart/form-data"

- "resource" content type "application/repository.semanticLayerDataSource+json" (assuming json)

- "resource" sent as content instead of file

- "resource" uses "schemaFile" property

 

Hopefully I can save someone else the untold hours I wasted!

 

Munged request below:

 

--

 


Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml, text/xml

Content-Type: multipart/form-data; boundary=-----------------------------28947758029299

Host: localhost

Content-Length: 393979

Accept-Encoding: gzip, deflate

 

-------------------------------28947758029299

Content-Type: application/repository.semanticLayerDataSource+json; charset=UTF-8

Content-Disposition: form-data; name="resource"

 

{

  "dataSource": {

    "dataSourceReference": {

      "uri": "/path/to/connection"

    }

  },

  "schema": {

    "schemaFile": {

      "label": "My_schema",

      "description": "My_schema",

      "type": "xml"

    }

  },

  "label": "A domain"

}

-------------------------------28947758029299

Content-Disposition: form-data; name="schema"; filename="schema.xml"

Content-Type: application/xml; charset=UTF-8

 

<?xml version="1.0" encoding="utf-8"?>

<schema version="1.0" xmlns="http://www.jaspersoft.com/2007/SL/XMLSchema">

[...rest of schema...]

</schema>

-------------------------------28947758029299--

 

Link to comment
Share on other sites

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...