使用tibco jasperreports服务器6.3.0并通过REST_V2端点添加资源。文件的资源描述符似乎很简单,这是我用来测试它的脚本:
#!/bin/bash
output=$(curl -sX POST "http://localhost:8080/jasperserver/rest_v2/resources/common/someFile.jrtx?createFolders=true"
-H "Content-Type:application/repository.query+json"
-H "Accept:application/json"
-d "{
"uri" :"/common/someFile.jrtx",
"label":"someFile.jrtx",
"description":"Some File",
"permissionMask":"0",
"type":"jrtx",
"content":"$(base64 -w 0 /path/to/someFile.jrtx)"
}"
--user jasperadmin:jasperadmin)
echo "${output}" | python -m json.tool
我为此获得的输出令人困惑:
[
{
"errorCode": "mandatory.parameter.error",
"message": "A value for the field QueryValue must be set",
"parameters": [
"QueryValue"
]
},
{
"errorCode": "mandatory.parameter.error",
"message": "A value for the field Language must be set",
"parameters": [
"Language"
]
}
]
文件的描述符都不提及这些字段(语言或QueryValue(,并且在手动创建文件时,我当然不必输入它们。我在做什么错?
JRTX文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperTemplate PUBLIC "-//JasperReports//DTD Template//EN" "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">
<jasperTemplate>
<style name="SimpleStyle"/>
<style name="ColumnHeading" hAlign="Center" vAlign="Middle" isBlankWhenNull="true" fontName="Verdana" fontSize="10" isBold="true">
<pen lineWidth="1.0" lineColor="#666565"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</style>
<style name="Title" markup="" fontSize="20" isBold="true"/>
<style name="TableCells" hAlign="Center" vAlign="Middle" isBlankWhenNull="true" fontName="Verdana" fontSize="10" isBold="false">
<pen lineWidth="1.0" lineColor="#CCCCCC"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#CCCCCC"/>
</box>
</style>
<style name="VerticalColumnHeading" hAlign="Center" vAlign="Middle" rotation="Left" fontName="Verdana" fontSize="12" isBold="true"/>
<style name="GroupHeading" hAlign="Left" vAlign="Middle" fontName="Verdana" fontSize="10">
<pen lineWidth="1.0" lineColor="#CCCCCC"/>
</style>
</jasperTemplate>
错误的内容类型。而不是这个
-H "Content-Type:application/repository.query+json"
我应该使用此:
-H "Content-Type:application/repository.file+json"