亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

對 NiFi 的 Java PUT 請求

對 NiFi 的 Java PUT 請求

一只甜甜圈 2021-08-04 10:35:02
我在向 nifi 發送簡單的 PUT 請求時遇到問題,基本上我想用 java 代碼啟動一個 nifi 處理器。錯誤消息 - 服務器返回 HTTP 響應代碼:URL 為 405:http://localhost:8080/nifi-api/processors/我應該采取什么步驟來解決這個 405 問題?nifi api 網站提供了有關 rest api 的高級文檔,但沒有關于如何使用 Java 向 NiFi 發出正確 PUT 請求的指南。import java.io.BufferedReader;import java.io.DataOutputStream;import java.io.InputStreamReader;import java.net.HttpURLConnection;import java.net.URL;import javax.net.ssl.HttpsURLConnection;public class HttpURLConnectionExample {    private final String USER_AGENT = "Mozilla/5.0";    public static void main(String[] args) throws Exception {        HttpURLConnectionExample http = new HttpURLConnectionExample();        System.out.println("\nTesting 2 - Send Http POST request");        http.sendPut();    }    // HTTP PUT request    private void sendPut() throws Exception {        String url = "http://localhost:8080/nifi-api/processors/";        URL obj = new URL(url);        HttpURLConnection con = (HttpURLConnection) obj.openConnection();        //add reuqest header        con.setRequestMethod("PUT");        con.setRequestProperty("Content-Type", "application/json");        con.setRequestProperty("Accept", "application/json");        con.setRequestProperty("text/javascript", "*/*");        String urlParameters = "{\r\n" +                 "  \"status\": {\r\n" +                 "    \"runStatus\": \"RUNNING\"\r\n" +                 "  },\r\n" +                 "  \"component\": {\r\n" +                 "    \"state\": \"RUNNING\",\r\n" +                 "    \"id\": \"749b3133-0162-1000-9acc-f384457b160c\"\r\n" +                 "  },\r\n" +                 "  \"id\": \"749b3133-0162-1000-9acc-f384457b160c\",\r\n" +                 "  \"revisions\": {\r\n" +                 "    \"version\": 1,\r\n" +                 "    \"clientId\": \"550c4b84-0165-1000-37be-724ed17b5329\"\r\n" +                 "}\r\n" +                 "  ";    }}
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 237 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號