I would like to be able to deploy reports to jasperserver using some kind of scripts, not via the Jaspersoft Studio GUI
I tried
js-export --uris /reports --output-dir myExportedReports
hoping to re-import the same.
However, while exploring the myExportedReports folder, there were only *.xml and associated *.data files without the original *.jrxml.
Did anyone deploy new reports (report folders) to Jasper Server without using Jaspersoft Studio?
So I checked out the Jasper Server REST interface.
It looks like a two steps process
Upload the JRXML file
JRXML_DATA=`cat "report.jrxml"`
curl -X POST http://localhost:8080/jasperserver/rest_v2/resources/reports/ \
-H "Content-Type:application/jrxml" \
-H "Content-Disposition:attachment; filename=My-report" \
-H "Content-Description:My-report-description" \
-d "$JRXML_DATA" \
--user jasperadmin:jasperadmin
Create the Report Unit and assign a data source
curl -X POST http://localhost:8080/jasperserver/rest_v2/resources/reports \
-H "Content-Type:application/repository.reportUnit+json" \
-d '{"uri": "/reports/my_report","label": "my-report","description": "My-report description", "permissionMask": "0", "version": "0" , "alwaysPromptControls": "true","controlsLayout": "popupScreen", "jrxml": {"jrxmlFileReference": { "uri": "/reports/my-report"} },"dataSource": {"dataSourceReference": { "uri": "/datasources/Reporting_DB"}}}' \
--user jasperadmin:jasperadmin
Related
I need to import all bug reports and attachments from my internal system to GitHub Issues.
What GitHub API parameter should I use to attach a document in my curl command?
curl -X "POST" \
-H "Accept: application/vnd.github+json" \
-H "Accept: application/vnd.github.VERSION.html" \
-H "Authorization: token <token>" \
https://api.github.com/repos/BT23/demo-repo/issues \
-d '{
"title":"Create an issue in HTML format",
"body":"<H1>Testing HTML tags</H1><P>Does it work?</P>",
"assignee": "BT23",
"milestone": 1,
"labels":["bug", "functional"]
}'
Thanks
I do not see the word file anywhere in Issues API.
And this thread confirms you cannot attach a file during Issue Creation.
Adding a file to issue or pull request seems to be done manually through drag & drop only.
I am trying to push a file to my folder called "collections" in my repository using curl.
I've spent almost 2 days investigating problem and I am not sure what is the exact problem.
curl -D- -k -X GET -H "PRIVATE-TOKEN: faNFKoC4-opiDJ0FJSk" https://gitlab.example.com/api/v4/projects/592/repository/tree?path=collections
Get request works properly and I get list of files in collections folder.
The collections folder is a folder in my gitlab repository
But when I try to POST a file to that exact same folder I get 404:
curl -D- -k -X POST -H "PRIVATE-TOKEN: faNFKoC4-opiDJ0FJSk" -F "file=#C:/Documents/Folder_A/bp30_QA.csv" https://gitlab.example.com/api/v4/projects/592/repository/tree?path=collections
Am I missing some parameter? also gitlab API didn't help me very much.
Edit: Solution from Bertrand Martel helped me solve the issue
Also for everyone on windows having trouble installing jq
jq is a lightweight and flexible command-line JSON processor.
Install choco: https://chocolatey.org/install
Open powershell as administrator and run:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
After installation, run:
choco install jq
To create a new file called bp30_QA.csv in the collections folder, you can use the following :
curl -H 'PRIVATE-TOKEN: YOUR_PRIVATE_TOKEN' \
-H "Content-Type: application/json" \
-d '{
"branch": "master",
"author_email": "johndoe#gmail.com",
"author_name": "John Doe",
"content": '"$(jq -Rs '.' bp30_QA.csv)"',
"commit_message": "create a new file"
}' "https://gitlab.com/api/v4/projects/592/repository/files/collections%2Fbp30_QA.csv"
It uses jq to wrap the content of the file in a single JSON field (check this post)
I am using sonar webapi to associate a project with a quality profile but not able to do it. On every run of sonnar-scanner it is associating default quality profile. Below is the code snippet.
Updated the code snippet
curl -k -X POST --insecure -H “X-Auth-Token:XXX” -d "language=py" -d "qualityProfile=test_profile" -d “project=test_1.0” https://sonartest.xxx.com/api/qualityprofiles/add_project
I am not sure what I am doing wrong. I have administrative access and followed the webapi of Version 6.7.3 (build 38370)
Finally got some help from Soanrqube community. I need to remove X-Auth-Token from code. It should be something like this
curl -u ur_token: -X POST -d language=py -d qualityProfile=test_profile -d projectKey=${params.ProjectName} https://sonar-url.com/api/qualityprofiles/add_project
I was trying to import dashboard using exported json file from one server to another server of grafana, but getting bellow error;
{"message":"Dashboard not found","status":"not-found"}
My curl command:
curl -X POST --insecure -H "Authorization: Bearer {API KEY}" -H "Content-Type: application/json" --data-binary #'{JSON file name}' http://{Host ip}:3000/api/dashboards/db
To export dashboard, I am using following curl command;
curl -f -k -H "Authorization: Bearer {API key}" "http://{Host IP}:3000/api/dashboards/db/mydashboard" | jq 'del(.overwrite,.dashboard.version,.meta.created,.meta.createdBy,.meta.updated,.meta.updatedBy,.meta.expires,.meta.version)' > {JSON file name}"
I am unable to find exact missing field OR value which is missing OR incorrectly passed through JSON file while importing. Is there any way to debug?
Is there any issue with my Export and import command.
As mentioned in this issue,
you must replace the "id": num field of the dashboard with null.
so you can change it for all of your dashboards (.json files) by command below: (works with GNU sed only)
sed -i '0,/"id": .*/{s/"id": .*/"id": null,/}' *.json
The simplest solution is to set the 'id' from root of the json to null.
"id": null,
Be aware, it's not the same field as uid in the end of the json (also root). That one must be unique, but not null.
I am using Visual Recognition curl command to add a classification to an image:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids=classifierlist.json" \
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classifiers?version=2015-12-02"
json file:
{
"classifiers": [
{
"name": "tomato",
"classifier_id": "tomato_1",
"created": "2016-03-23T17:43:11+00:00",
"owner": "xyz"
}
]
}
(Also tried without the classifiers array. Got the same error)
and getting an error:
{"code":400,"error":"Cannot execute learning task : no classifier name given"}
Is something wrong with the json?
To specify the classifiers you want to use you need to send a JSON object similar to:
{"classifier_ids": ["Black"]}
An example using Black as classifier id in CURL:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids={\"classifier_ids\":[\"Black\"]}"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"
If you want to list the classifier ids in a JSON file then:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids=#classifier_ids.json"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"
Where classifier_ids.json has:
{
"classifier_ids": ["Black"]
}
You can test the Visual Recognition API in the API Explorer.
Learn more about the service in the documentation.
The model schema you are referencing, and what is listed in the API reference, is the format of the response json. It is an example of how the API will return your results.
The format of the json that you use to specify classifiers should be a simple json object, as German suggests. In a file, it would be:
{
"classifier_ids": ["tomato_1"]
}
You also need to use < instead of # for the service to read the contents of the json file correctly. (And you might need to quote the < character on a command line since it has special meaning (redirect input).) So your curl would be:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids=<classifier_ids.json"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"