2017-04-20 30 views
1

當我嘗試使用下面的方法調用getstream API來保存活動(JSON)時,我得到以下異常。偶爾會發生此異常。我們如何解決這個問題?InvalidOrMissingInputException調用gestream API時

JSON:(activityTask)
{ 
    "processingType": "PERSIST_AND_NOTIFY", 
    "carbookBaseActivity": { 
     "actor": "7d8d59d1-1997-4213-81c0-32de463466f6", 
     "verb": "favorite", 
     "object": "{\"city\":\"Weimar\",\"postcode\":\"99423\",\"street\":\" Ernst-Thälmann-Straße\",\"housenumber\":\"\",\"countrycode\":\"DE\",\"county\":\"\",\"suburb\":\"\",\"state\":\"\",\"geopoint\":{\"lon\":11.3224816,\"lat\":50.9887822,\"alt\":0.0}}", 
     "target": "NA", 
     "time": "2017-04-17T08:43:09.527", 
     "to": [], 
     "acted": false, 
     "timeToLive": 1492591389527, 
     "userClusterId": "f7e3e39e-22a3-48c5-a043-f439e23b9bb2", 
     "label": "OFFICE", 
     "pictureUrl": "NA", 
     "status": 0, 
     "addressType": "OFFICE", 
     "foreign_id": "8ad1b071-e45d-4993-b077-ca843f137322", 
     "carbookBaseType": "TASK" 
    } 
} 
方法

CarbookBaseActivity response = flatActivityService.addActivity(activityTask);

異常
io.getstream.client.exception.InvalidOrMissingInputException 
    at io.getstream.client.apache.repo.handlers.StreamExceptionHandler.handleResponseCode(StreamExceptionHandler.java:73) ~[stormjar.jar:?] 
    at io.getstream.client.apache.repo.StreamActivityRepository.handleResponseCode(StreamActivityRepository.java:266) ~[stormjar.jar:?] 
    at io.getstream.client.apache.repo.StreamActivityRepository.addActivity(StreamActivityRepository.java:103) ~[stormjar.jar:?] 
    at io.getstream.client.apache.repo.StreamRepositoryImpl.addActivity(StreamRepositoryImpl.java:199) ~[stormjar.jar:?] 
    at io.getstream.client.service.AbstractActivityService.addActivity(AbstractActivityService.java:69) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.operation.ActivityOperation.handleLocationPredicitionTask(ActivityOperation.java:230) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.operation.ActivityOperation.handleCarbookBaseActivity(ActivityOperation.java:115) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.operation.ActivityOperation.handleActivity(ActivityOperation.java:73) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.extract.ActivityBolt.execute(ActivityBolt.java:89) [stormjar.jar:?] 
    at backtype.storm.topology.BasicBoltExecutor.execute(BasicBoltExecutor.java:50) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.daemon.executor$fn__4273$tuple_action_fn__4275.invoke(executor.clj:670) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.daemon.executor$mk_task_receiver$fn__4196.invoke(executor.clj:426) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.disruptor$clojure_handler$reify__3772.onEvent(disruptor.clj:58) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:125) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:99) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:80) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.daemon.executor$fn__4273$fn__4286$fn__4337.invoke(executor.clj:808) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.util$async_loop$fn__543.invoke(util.clj:475) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at clojure.lang.AFn.run(AFn.java:22) [clojure-1.6.0.jar:?] 
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60] 
2017-04-17 14:41:10.461 b.s.d.executor [ERROR] 
io.getstream.client.exception.InvalidOrMissingInputException 
    at io.getstream.client.apache.repo.handlers.StreamExceptionHandler.handleResponseCode(StreamExceptionHandler.java:73) ~[stormjar.jar:?] 
    at io.getstream.client.apache.repo.StreamActivityRepository.handleResponseCode(StreamActivityRepository.java:266) ~[stormjar.jar:?] 
    at io.getstream.client.apache.repo.StreamActivityRepository.addActivity(StreamActivityRepository.java:103) ~[stormjar.jar:?] 
    at io.getstream.client.apache.repo.StreamRepositoryImpl.addActivity(StreamRepositoryImpl.java:199) ~[stormjar.jar:?] 
    at io.getstream.client.service.AbstractActivityService.addActivity(AbstractActivityService.java:69) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.operation.ActivityOperation.handleLocationPredicitionTask(ActivityOperation.java:230) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.operation.ActivityOperation.handleCarbookBaseActivity(ActivityOperation.java:115) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.operation.ActivityOperation.handleActivity(ActivityOperation.java:73) ~[stormjar.jar:?] 
    at de.carbook.storm.activity.extract.ActivityBolt.execute(ActivityBolt.java:89) [stormjar.jar:?] 
    at backtype.storm.topology.BasicBoltExecutor.execute(BasicBoltExecutor.java:50) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.daemon.executor$fn__4273$tuple_action_fn__4275.invoke(executor.clj:670) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.daemon.executor$mk_task_receiver$fn__4196.invoke(executor.clj:426) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.disruptor$clojure_handler$reify__3772.onEvent(disruptor.clj:58) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:125) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:99) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:80) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.daemon.executor$fn__4273$fn__4286$fn__4337.invoke(executor.clj:808) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at backtype.storm.util$async_loop$fn__543.invoke(util.clj:475) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485] 
    at clojure.lang.AFn.run(AFn.java:22) [clojure-1.6.0.jar:?] 
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60] 
響應
InvalidOrMissingInputException 
{statusCode=400, code=4, exception=InputException, detail=Errors for fields 'object'} 
+0

當您收到4xx錯誤時,您是否已經查看了響應主體?應該有一條JSON編碼的消息,其中包含有關活動負載中哪些內容無效的信息 –

+0

我試過重新發送相同的JSON,在回覆中我收到了** _響應_ ** –

+0

@TommasoBarbugli我發送的對象是json字符串。 –

回答

1

的演員,對象和動詞領域中必須是ASCII編碼的值,在你的例子我看到你發送的非ASCII字符,如ßä。我很驚訝你沒有在響應主體中看到明確的驗證錯誤,我建議你在你正在使用的API客戶端的Github回購站上打開一個問題,或直接訪問Stream支持。稍微脫離主題:我看到你在活動中存儲相當複雜的數據。雖然這得到API的支持,但一般建議是隻保留對數據的引用。這樣做可以更輕鬆地更新活動中的數據。

例如:經緯度永遠不會改變,但您代表他們的方式可能會。

+0

當然會提高票。關於活動數據的複雜性,我們正在爲我們的大部分數據開發固定鏈接,因此我們可以減少這些問題。感謝您的幫助和信息。 –