2

我有一个烦人的问题,我不确定是否有人知道答案,但询问没有任何成本。

我正在使用 Domino-Data-Service Rest-API 通过 PATCH-Methode 将 PDF 文件附加到服务器。附件确实可以正常工作,但富文本字段中的附件确实有一个自动生成的名称。

我的问题:如何通过附加来更改此文件的名称。

我用 C# 编写了我的代码,但我认为这不是依赖于编程语言的问题。

我附加 PDF (C#) 的代码:

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes({username:passwort})));

Byte[] bytes = File.ReadAllBytes(@"H:\jakob.pdf");
String file = Convert.ToBase64String(bytes);

var json = "{" + 
           "\"anmerkung\":{" +
           "\"type\":\"multipart\"," +
           "\"content\":[ {" +
                      "\"contentType\":\"application/pdf\"," +
                      "\"data\":\"" + file + "\"," +
                      "\"contentTransferEncoding\":\"base64\"" +
                                                           "}" +
                                                           "]" +
                          "}" +
           "}";

var data = new StringContent(json, Encoding.UTF8, "application/json");
var url = @"https://{database}/api/data/documents/unid/424CC34CFB0746F6C12585A7003B277B?computewithform=true&form={formname}";

var response = await client.PatchAsync(url, data);

string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
client.Dispose();

这工作正常,但我的 PDF 看起来像这样:

在此处输入图像描述

我希望 pdf 文件的名称为jakob.pdf

所以我尝试重建 json,就像在使用 GET-Request 到富文本字段中带有 PDF 文件的文档时构建 json 的方式

我使用重建 json(C#) 附加 PDF 的代码:

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes({username:passwort})));

Byte[] bytes = File.ReadAllBytes(@"H:\jakob.pdf");
String file = Convert.ToBase64String(bytes);


var json2 = "{" +
            "\"anmerkung\":{" +
            "\"type\":\"multipart\"," +
            "\"content\":[ {" +
                       "\"contentType\":\"application/pdf; name=\"jakob.pdf\"\","+
                       "\"contentDisposition\":\"inline; filename=\"jakob.pdf\"\","+
                       "\"data\":\"" + file + "\"," +
                       "\"contentTransferEncoding\":\"base64\"" +
                                                            "}" +
                                                            "]" +
                          "}" +
            "}";

var data = new StringContent(json2, Encoding.UTF8, "application/json");
var url = @"https://{database}/api/data/documents/unid/424CC34CFB0746F6C12585A7003B277B?computewithform=true&form={formname}";

var response = await client.PatchAsync(url, data);

string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
client.Dispose();

当我使用这段代码时,我总是收到一条错误消息:

"code":400,
"text":"Bad Request",
"message":"Fehler beim Parsen der JSON-Inhalte",
"type":"text",
"data":"com.ibm.domino.services.ServiceException: Fehler beim Parsen der JSON-Inhalte\r\n\tat

关于这段代码,我什至不确定,如果这段代码正常工作,那只是一个想法,我试过了。

我知道这是一个非常复杂和困难的问题,但也许有人知道这个问题的答案或者有一些想法来解决这个问题。

提前致谢!

4

2 回答 2

4

错误响应的最可能原因是,当您在 JSON 中设置文件名时,您创建了格式错误的 JSON。

以您的单行代码为例,由于文件名周围的引号字符,此行是格式错误的 JSON:

    "\"contentType\":\"application/pdf; name=\"jakob.pdf\"\","+

contentDisposition有同样的问题。

我强烈建议使用旨在将结构化对象转换为适当的序列化 JSON 的 API,这应该可以轻松避免该问题,但我不知道 C# 中有什么可用于此目的。

以下页面底部的列表可能会有所帮助:https ://www.json.org/json-en.html

于 2020-07-23T07:22:21.443 回答
0

我为所有感兴趣的人提供了解决方案,如果您希望代码正常工作,JSON 必须看起来像这样。

JSON:

干净地格式化它看起来像这样:

{
    "nachname": "Rindberger",
    "anmerkung": {
        "type": "multipart",
        "content": [{
            "contentType": "application/pdf; name=\"jakob.pdf\"",
            "contentDisposition": "attachment; filename=\"jakob.pdf\"",
            "data": "JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFuZyhkZS1BVCkgL1N0cnVjdFRyZWVSb290IDEwIDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cn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DAwMDA0NTEgMDAwMDAgbg0KMDAwMDAwMDgxNyAwMDAwMCBuDQowMDAwMDAxMDAxIDAwMDAwIG4NCjAwMDAwMDEyNTcgMDAwMDAgbg0KMDAwMDAwMTMxMCAwMDAwMCBuDQowMDAwMDAxMzYzIDAwMDAwIG4NCjAwMDAwMDAwMTEgNjU1MzUgZg0KMDAwMDAwMDAxMiA2NTUzNSBmDQowMDAwMDAwMDEzIDY1NTM1IGYNCjAwMDAwMDAwMTQgNjU1MzUgZg0KMDAwMDAwMDAxNSA2NTUzNSBmDQowMDAwMDAwMDE2IDY1NTM1IGYNCjAwMDAwMDAwMDAgNjU1MzUgZg0KMDAwMDAwMTk3NiAwMDAwMCBuDQowMDAwMDAyMTI1IDAwMDAwIG4NCjAwMDAwMDYwNzYgMDAwMDAgbg0KdHJhaWxlcg0KPDwvU2l6ZSAyMC9Sb290IDEgMCBSL0luZm8gOSAwIFIvSURbPEZEREE3MDIxMzlBQkIzNEZBNDQyNjBCNDlCQUIxQTVGPjxGRERBNzAyMTM5QUJCMzRGQTQ0MjYwQjQ5QkFCMUE1Rj5dID4+DQpzdGFydHhyZWYNCjYzNTMNCiUlRU9GDQp4cmVmDQowIDANCnRyYWlsZXINCjw8L1NpemUgMjAvUm9vdCAxIDAgUi9JbmZvIDkgMCBSL0lEWzxGRERBNzAyMTM5QUJCMzRGQTQ0MjYwQjQ5QkFCMUE1Rj48RkREQTcwMjEzOUFCQjM0RkE0NDI2MEI0OUJBQjFBNUY+XSAvUHJldiA2MzUzL1hSZWZTdG0gNjA3Nj4+DQpzdGFydHhyZWYNCjY5MDgNCiUlRU9G",
            "contentTransferEncoding": "base64"
        }]
    }
}

在代码中它看起来像这样(C#):

var json = "{" +
                      "\"nachname\":\"Rindberger\"," +
                      "\"anmerkung\":{" +
                                "\"type\":\"multipart\"," +
                                "\"content\":[ {" +
                                            "\"contentType\":\"application/pdf; name=\\\"jakob.pdf\\\"\"," +
                                            "\"contentDisposition\":\"attachment; filename=\\\"jakob.pdf\\\"\"," +
                                            "\"data\":\"" + file + "\"," +
                                            "\"contentTransferEncoding\":\"base64\"" +
                                            "}" +
                                "]" +
                                "}" +
                      "}";
于 2020-07-24T08:42:09.130 回答