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

How to create datasource using REST v1 api


vgaikwad

Recommended Posts

Hi,

I am using the resource ("rest/resource") v1 rest api. and want to create a datasource on the server. As per the documentation I am using a plain vanilla web request (btw I am in c#).

http-method = "PUT"

content-type = "text/plain;  boundary={boundaryvalue}"

Payload looks like this:

--1afdzzMUQLfSOmu0Pgb2F-nmEnTwWuPf3
Content-Disposition: form-data; name="local"
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
<resourceDescriptor name="local" wsType="custom" uriString="/datasources" isNew="true">
<label><![CDATA[local]]></label>
<creationDate></creationDate>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.CustomReportDataSource]]></value>
</resourceProperty>
<resourceProperty name="PROP_PARENT_FOLDER">
<value><![CDATA[/datasources]]></value>
</resourceProperty>
<resourceProperty name="PROP_VERSION">
<value><![CDATA[0]]></value>
</resourceProperty>
<resourceProperty name="PROP_SECURITY_PERMISSION_MASK">
<value><![CDATA[33]]></value>
</resourceProperty>
<resourceProperty name="PROP_DATASOURCE_CUSTOM_SERVICE_CLASS">
<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.service.ReportDataAdapterService]]></value>
</resourceProperty>
<resourceProperty name="PROP_DATASOURCE_CUSTOM_PROPERTY_MAP">
<resourceProperty name="fileName">
</resourceProperty>
<resourceProperty name="_cds_name">
<value><![CDATA[jsonDataSource]]></value>
</resourceProperty>
</resourceProperty>
<resourceProperty name="PROP_HAS_DATA">
<value><![CDATA[true]]></value>
</resourceProperty>
</resourceDescriptor>
--1afdzzMUQLfSOmu0Pgb2F-nmEnTwWuPf3--
 
 
On sending this to server I get "The remote server returned an error: (403) Forbidden" error.
 
Any help is much appreciated. 

I have also tried changing the follow:

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

It still give me the same error.

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi hozawa,

Thanks for the response, that is not the case, I can change the pay load and create fodler. The session is created for a organization_1 > jasperadmin user which is kind of a administration profile.

Are there any working examples of the same? (i.e. creating datasource using resource api v1)

Thanks

 

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