2017-08-31 70 views
2

我正在嘗試使用Wolkenkit的REST API發送命令。我沒有在文檔中找到任何信息,所以我試圖通過源代碼和單元測試來找到必要的信息。用於發送命令的Wolkenkit REST API返回「格式錯誤的命令」

我使用HTTPie做從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 console驗證aggregate.id是正確的。 command.id只是一個隨機uuid()

我作爲迴應得到了Malformed command我錯了什麼?

回答

2

聲明:我是wolkenkit的開發人員之一。

在內部,命令是使用commands-events模塊構建的,該模塊也用於驗證傳入命令。

實際的錯誤來自tailwind wolkenkit在引擎蓋下作爲使用命令和事件的應用程序的基礎使用。在內部,這個代碼calls the isWellformed functioncommands-events,這又是checks the schema的命令。

從我看到的一切似乎都很好,除了metadata.timestamp應該是number,而不是string。我認爲如果你改變這個,那麼wolkenkit會很樂意接受你的命令。

+1

偉大的,那有效。如果響應包含驗證失敗時的實際錯誤消息,那麼可能會有所幫助。 – Alp