使用TIBCO JasperReports Server 6.3.0并通过rest_v2端点添加资源。 resource descriptor for file似乎相当简单,这是我用来测试它的脚本:
#!/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"
]
}
]
FILE的描述符没有提到这些字段(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>
答案 0 :(得分:0)
内容类型错误。而不是这个
-H "Content-Type:application/repository.query+json" \
我应该用这个:
-H "Content-Type:application/repository.file+json" \