【问题标题】:how to post a text file to jasper reports server using rest v2 with json如何使用带有 json 的 rest v2 将文本文件发布到 jasper 报告服务器
【发布时间】:2014-09-25 15:32:29
【问题描述】:

我正在尝试使用 POST/json 请求向 JasperReports 服务器(5.6.0 版本)发送一个简单的 txt 文件。发布后我不断收到客户端 400 错误。我已经阅读了文档,但无法弄清楚出了什么问题。如果有人可以为发送小 txt 文件的示例请求发布确切的标头和 json 内容,我将不胜感激。我无法理解的一件事是帖子标题是否正确。在“内容标题类型”部分的http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/v2resources-service 中有很多讨论,但没有具体示例,所以我不确定应该为标题提供什么,比如“txt”文件(我只是使用香草'Content-type': 'application/json' 但我怀疑这可能是错误的)。

以下是我的标题和内容(为了便于阅读,我对其进行了编辑,内容是 uu64 编码的):

Post URL=http://jasperserver:8080/jasperserver/rest_v2/resources/Reports/images/xyzzy
JsonData=
{   
    "content": 
        "3eHJ3eHJ3eCsgMSBBZG1pbmlzdHJhdG9ycyBOb25lICAgICAgI
            [clipped]
        sIDI5IDA5OjU2IHNjcmlwdHMKZHJ3eHJ3eHJ3eCsgMSBBZG1pb",
    "type": "txt", 
    "label": "Sample Label"
}
PostHeaders={'Content-type': 'application/json', 'accept': 'application/json'}

【问题讨论】:

  • 我能够弄清楚这一点。问题实际上是我的帖子标题。它必须是: PostHeaders={'Content-type': 'application/repository.file+json', 'accept': 'application/json'} 我在问题中显示的其他所有内容都是正确的。

标签: json rest jasper-reports http-post jasperserver


【解决方案1】:

我能够弄清楚这一点。问题实际上是我的帖子标题。它必须是:

PostHeaders={
    'Content-type': 'application/repository.file+json', 
    'accept': 'application/json'
}

我在问题中显示的所有其他内容都是正确的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-04
    • 2016-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多