簡體   English   中英

使用vertx.io Web客戶端未成功

[英]Using vertx.io web client with no success

我正在研究vertx.io Web客戶端,已經被禁止進行簡單的獲取。 這是我整理的內容(在vertx.io我很新):

private void getUserEmail(String accessToken, Handler<AsyncResult<String>> handler) {
  String url = "https://graph.facebook.com/me";
  HttpRequest<JsonObject> req = webClient.get(url).as(BodyCodec.jsonObject());
  req.addQueryParam("access_token", accessToken);
  req.addQueryParam("fields", "name,email");
  MultiMap headers = req.headers();
  headers.set("Accept", "application/json");
  req.send(h -> {
    if (h.succeeded()) {
      log.info(h.result().toString());
      handler.handle(new FutureFactoryImpl().succeededFuture(h.result().bodyAsString()));
    } else {
      log.error(h.cause());
      handler.handle(new FutureFactoryImpl().failedFuture(h.cause()));
    }
  });
}

我認為應該足夠了,但事實並非如此。 當我發送請求時,我得到這個錯誤:

io.vertx.core.json.DecodeException: Failed to decode: Unrecognized token 'Not': was expecting 'null', 'true', 'false' or NaN
at [Source: Not Found; line: 1, column: 4]

當然,如果我通過瀏覽器執行相同的操作,則會獲得預期的數據。 我閱讀了教程並檢查了示例,我缺少了什么?

您收到以下內容的404錯誤: Not Found ,編解碼器嘗試將其解析為JSON並失敗。 您需要驗證您發送的請求是否正確。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM