用于发送命令的 Wolkenkit REST API 返回“格式错误的命令" [英] Wolkenkit REST API for sending commands returns "Malformed command"

查看:36
本文介绍了用于发送命令的 Wolkenkit REST API 返回“格式错误的命令"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Wolkenkit 的 REST API 发送命令.我没有在文档中找到任何信息,所以我试图通过查看源代码和单元测试来找到必要的信息.

I am trying to use the REST API of Wolkenkit to send a command. I did not find any information in the docs, so i tried to find what is necessary by going through the source code and unit tests.

我正在使用 HTTPie 来处理来自 cli 的请求:

I am using HTTPie to do requests from the cli:

> http --verbose post https://local.wolkenkit.io:3500/v1/command id=12bf5b37-e0b8-42e0-8dcf-dc8c4aefc000 context:='{"name": "mycontext"}' aggregate:='{"name": "label", "id": "26c01e1f-abb8-42fa-82cf-60ca4a6bfbfa"}' name=create data:='{"label": "third"}' custom:='{}' metadata:='{"timestamp": "1504167240279", "correlationId": "12bf5b37-e0b8-42e0-8dcf-dc8c4aefc000", "causationId": "12bf5b37-e0b8-42e0-8dcf-dc8c4aefc000"}'

POST /v1/command HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 405
Content-Type: application/json
Host: local.wolkenkit.io:3500
User-Agent: HTTPie/0.9.9

{
    "aggregate": {
        "id": "26c01e1f-abb8-42fa-82cf-60ca4a6bfbfa",
        "name": "label"
    },
    "context": {
        "name": "mycontext"
    },
    "custom": {},
    "data": {
        "label": "third"
    },
    "id": "12bf5b37-e0b8-42e0-8dcf-dc8c4aefc000",
    "metadata": {
        "causationId": "12bf5b37-e0b8-42e0-8dcf-dc8c4aefc000",
        "correlationId": "12bf5b37-e0b8-42e0-8dcf-dc8c4aefc000",
        "timestamp": "1504167240279"
    },
    "name": "create"
}

HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate
Connection: keep-alive
Content-Length: 18
Content-Type: text/html; charset=utf-8
Date: Wed, 30 Aug 2017 20:57:27 GMT
ETag: W/"12-2BIyYXjsDfNWq9+GqVAfSCeA8D4"
Expires: 0
Pragma: no-cache
Surrogate-Control: no-store
X-FRAME-OPTIONS: DENY
X-Powered-By: Express
X-XSS-Protection: 1; mode=block

Malformed command.

我使用 wolkenkit 控制台 来验证 aggregate.id 是否正确.command.id 只是一个随机的 uuid().

I used wolkenkit console to verify that the aggregate.id is correct. The command.id is just a random uuid().

Malformed command 作为响应我做错了什么?

What did i wrong to get Malformed command as response?

推荐答案

免责声明:我是 wolkenkit 的开发者之一.

在内部,命令是使用 commands-events 模块构建的,该模块也正在用于验证传入的命令.

Internally, the commands are built using the commands-events module, which also is being used for verifying incoming commands.

实际错误来自tailwind,wolkenkit 在后台使用它作为使用命令和事件的应用程序的基础.在内部,此代码 调用isWellformed 函数 commands-events,反过来又检查命令的架构.

The actual error comes from tailwind which wolkenkit uses under the hood as base for an application that uses commands and events. Internally, this code calls the isWellformed function of commands-events, which in turn checks the schema of the command.

从我看来,一切似乎都很好,除了 metadata.timestamp 应该是 number,而不是 string.我想如果你改变这个,那么 wolkenkit 会很乐意接受你的命令.

From what I see everything seems to be fine, except that metadata.timestamp should be a number, not a string. I think that if you change this, then wolkenkit will accept your command happily.

这篇关于用于发送命令的 Wolkenkit REST API 返回“格式错误的命令"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆