REST Web Service API: upload/update report template - rest

I want to store and deploy report template with my code.
With this one in mind running a report is a two step process:
upload or update existing report template jrxml (it does not have links to other resources like images)
run it with my data (this one is done)
The official documentation doesn't contain a minimal example for updating report template
What is raw request which uploads/updates report template xml via JasperReports Server REST API?
I tried this way
here is my raw request
here is response
here what I see in /var/lib/tomcat6/webapps/jasperserver/WEB-INF/logs/jasperserver.log
What am I doing wrong? What does 400 error: could not find the binary content for resource: /Reports/product_structures_workshops mean?

This works for Jasper 5.5+ (but does not for 5.1-, returns just 404 Not Found "Specified page not found" instead).
Uploading
POST http://your-host:port/jasperserver/rest_v2/resources/path/to/resource/
Content-Type: application.repository.reportUnit+json
{
"label": "Sample",
"jrxml": {
"jrxmlFile": {
"label": "MyJRXML",
"type":"jrxml",
// encode your file in Base64 and put here
"content": "PD94bWwg..."
}
}
}
Updating
PUT http://your-host:port/jasperserver/rest_v2/resources/path/to/resource/myReport/
Content-Type: application.repository.reportUnit+json
{
"label": "Sample",
"jrxml": {
"jrxmlFile": {
"label": "MyJRXML",
"type":"jrxml",
// encode your file in Base64 and put here
"content": "PD94bWwg..."
}
}
}
References:
https://community.jaspersoft.com/questions/822949/example-creating-report-resource-rest-v2
http://community.jaspersoft.com/sites/default/files/docs/jasperreports-server-web-services-guide.pdf

We ended up with writing proprietary local JAVA application with jasper libraries, which does same thing
It looks like this is doable in older jasper versions (> 5.2):
they simplified significally REST API (look for API v2)
https://community.jaspersoft.com/wiki/getting-started-rest-web-service-api
With the completion of the v2 REST API, Jaspersoft announces the
deprecation of the original REST API and the end-of-life of the SOAP
services

Related

SSRS Rest API report patch doesn't update parameters

I have rdl files locally, and I want to use SSRS Rest API to update the reports in the report server (if there are any changes.)
I am using PATCH to send the request to the report server. Like this
BaseUrl: http://<report_server_ip>/reports/api/v2.0/reports(d0d2791e-b332-4d45-a233-579e86c1fc70)
Method: PATCH
Content Type: application/json
Body:
{
"Name":"My Report",
"Description": "",
"Path": "/Test/My Report",
"Type": "Report",
"Hidden": false,
"Content":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxSZXBvcnQgTXVzdFVuZGVyc3RhbmQ9ImRmIiB..."
}
For Content, I open the rdl file and read all bytes and convert it to Base64 string. Like this:
content=File.ReadAllBytes(path) //path is the local rdl file path
Convert.ToBase64String(ASCII.GetBytes(content))
If I open the rdl file in a text editor (Notepad++), I see that the report parameter XML node has changes but when I send the PATCH request, the report parameters in the report server are not updated.
Here is the link to the SSRS Rest API: https://app.swaggerhub.com/apis/microsoft-rs/SSRS/2.0#/Reports/UpdateReport
In order to update parameters using SSRS Rest API, you must pass HasParameters: true in the body.
If HasParameters is not set then the API will not update the parameters.

How can I include JSON body API examples in Swagger2Markup API requirements (when converting from Swagger YAML)?

I've used the Swagger editor (editor.swagger.io) to create API requirements that look great online in a web browser, but I want to convert this Swagger YAML documentation into a format that can be printed (Word, PDF, Excel, HTML) and read offline.
The only way I've seen to convert the Swagger YAML into a clean, printable API requirements document is using the Swagger2Markup CLI (here's the reference documentation: http://swagger2markup.github.io/swagger2markup/1.3.3/ - Chapter 8 describes the CLI), then converting this adoc format to HTML from AsciiDoctor. The final product is very readable as you can see from the Swagger2Markup reference documentation.
However, unfortunately, the final Swagger2Markup documentation of an API doesn't include JSON or xml examples of the API body, which is arguably the most important part of the documentation in my opinion! For example, in the Swagger editor's petstore, this would be the json body example for the POST /pet API:
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
But this JSON example isn't included in the Swagger2Markup documentation.
So my question is, is it possible to update Swagger2Markup (or change the Swagger2Markup properties) to include JSON body API examples in the final document?
If not, is there a different way you recommend converting Swagger YAML into a readable document that includes JSON body API examples?
To add json body API examples to the adoc with swagger2markup, create a config file (config.properties) and add "swagger2markup.generatedExamplesEnabled=TRUE". Per the swagger2markup reference document, section 3.2.5, this property specifies if http rquest and response examples should be generated. Awesome!

Service Fabric Client REST API - Syntax for parameters in body

I'm trying to use the client rest api to upgrade an application. I can get the application types, version etc using the api but I'm struggling when trying the "Start Application Upgrade". The problem looks like it's with the encoding of the Application Upgrade Description, all the ways I've tried I can't get past
{
"Error": {
"Code": "FABRIC_E_INVALID_NAME_URI",
"Message": "Invalid name URI."
}
}
I could be way off but I'm using JSON format like below for the body:
{
"ApplicationUpgradeDescription":{
"Name":"fabric:/twinpeaks",
"TargetVersion":"1.0.1",
…..other params as per spec
}
Any pointers?
Cheers
Close but not quite.. The body just needs to be:
{
"Name":"fabric:/twinpeaks",
"TargetApplicationTypeVersion":"1.1.0",
….. etc
}
Once I made this change the upgrade was accepted, all good.

Content Server - How to add Classification in a document (node )from REST API

I am developing an Java app to upload documents in Content Server 16.2 using REST API.
I need add a defined classification to a document (node) via REST API but I'm not found how to do.
For example:
This is my REST call:
POST http://<server>/OTCS/cs.exe/api/v2/nodes
And two parameters:
body {
"parent_id": "137072",
"name": "example.tmp",
"type": "144"
}
file: (a MultipartFile)
Is it possible?
You should use Record Management services:
https://developer.opentext.com/webaccess/#url=%2Fawd%2Fresources%2Fapis%2Frecords-management-v1&tab=501
I confirm you that are available for 16.0 and 16.2 as well.
This post worked for me on 16.0.7:
where payload is:
R.

I keep getting error 422 when trying to start process instance using REST API

I'm trying to use the REST API, from Postman REST client on Chrome.
Here's my screenshot:
I keep getting error 422: "The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions".
I'm using Activiti 5.16.3 on MacOS Maverick, with Java 1.8.
The process I tried to call is the one that comes with the demo of Activiti, Vacation Request.
The JSON payload in my request is:
{
"processDefinitionKey":"vacationRequest",
"variables":[
{"name": "employeeName", "value": "Raka","type":"string"},
{"name": "numberOfDays", "value": "5", "type":"integer"},
{"name": "vacationMotivation", "value": "", "type":"string"},
{"name": "startDate", "value": "01-01-2014 11:11", "type":"date"}
]
}
Oh, and I had to add a header "Content-Type" with its value set to "application/json" (otherwise I'd get error code 415: "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method").
What am I missing?
Btw, I need to be able to demonstrate the use of the REST API through tools like Postman. So, no Java code. It's because another programmer (front-end) will interact directly with Activiti bpm.
Thanks in advance for your help. This is really critical.
**
Additional comments:
I didn't have issue with other REST methods that are GET (for example: listing process definitions, etc). Looks like I'm only having trouble with POST (and maybe PUT too).
Not much info on this on google: https://www.google.com/search?as_q=rest+422&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforums.activiti.org&as_occt=any&safe=images&as_filetype=&as_rights=&gws_rd=ssl
I've tried also this suggestion. Didn't work for me: http://forums.activiti.org/comment/23039#comment-23039
**
Best regards,
Raka
Solved now....
Looks like there should be no whitespace between the opening { and the rest of the document.
Here's my screenshot: