Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Отправка TemplateToPost #1085

Open
KirillSagach opened this issue Jul 25, 2024 · 2 comments
Open

Отправка TemplateToPost #1085

KirillSagach opened this issue Jul 25, 2024 · 2 comments

Comments

@KirillSagach
Copy link

Всем привет!
Подскажите, пожалуйста, никак не пойму в чем проблема.
Отправляю POST-запрос "PostTemplate":

{
"FromBoxId": "9bfe09f4-b15b-44df-b31b-8a5b1f79a632",
"ToBoxId": "57aca62f-47d3-46eb-bb31-2583cc4d3ab4",
"MessageFromBoxId": "57aca62f-47d3-46eb-bb31-2583cc4d3ab4",
"MessageToBoxId": "9bfe09f4-b15b-44df-b31b-8a5b1f79a632",
"DocumentAttachments": [
{
"UnsignedContent": {
"NameOnShelf": "УПД"
},
"TypeNamedId": "UniversalTransferDocument",
"Function": "СЧФДОП",
"Version": "utd820_05_01_01_hyphen"
}
]
}

В итоге ошибка 400: Can't deserialize request body into type TemplateToPost: Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see https://stackoverflow.com/q/2152978/23354.

Что я делаю не так?
Есть подозрение, что это из-за того, что я не задал в элементе списка "DocumentAttachment" Metadata. Я знаю, как полкчить список метадат для конкретного тип/ функции/версии документа, но ведь у нас просто шаблон, а здесь https://developer.kontur.ru/Docs/diadoc-api/proto/TemplateDocumentAttachment.html сказано, что в Metadata должны быть пары ключ-значение, а в шаблоне не может быть значений - там же только ключи

@KirillSagach
Copy link
Author

А может вообще проблема в кодировке, но я делал и так:

ЗапросPostTemplate.УстановитьТелоИзСтроки(ТелоЗапроса,"Windows-1251");
ОтветPostTemplate = HTTP.ОтправитьДляОбработки(ЗапросPostTemplate);

и так:

ЗапросPostTemplate.УстановитьТелоИзСтроки(ТелоЗапроса);
ОтветPostTemplate = HTTP.ОтправитьДляОбработки(ЗапросPostTemplate);

Результат не меняется

@GilimkhanovDenis GilimkhanovDenis transferred this issue from diadoc/diadocsdk-1c-docs Jul 25, 2024
@E-k-u-t
Copy link

E-k-u-t commented Aug 15, 2024

а попробуй реально добавить Metadata

{
    "FromBoxId": "[email protected]",
    "ToBoxId": "[email protected]",
    "DocumentAttachments": [
        {
            "TypeNamedId": "Contract",
            "NeedReceipt": false,
            "SignedContent": {
                "Content": "Base64",
                "Signature": "Base64"
                // Пример содержимого файла, закодированного в Base64
            },
            "Metadata": [
                {
                    "Key": "FileName",
                    "Value": "test.txt"
                },
                {
                    "Key": "DocumentNumber",
                    "Value": "196"
                },
                {
                    "Key": "DocumentDate",
                    "Value": "27.10.2017"
                },
                {
                    "Key": "ContractType",
                    "Value": "Купля-продажа-Тестовая заявка!!!"
                },
                {
                    "Key": "ContractPrice",
                    "Value": "1.00"
                }
            ]
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants