URL url3 = new URL("https://52.36.28.121/sap/opu/odata/ACNLQD/ALPS_SRV/CourseActivitySet");
URLConnection con = url3.openConnection();
HttpURLConnection http = (HttpURLConnection)con;
http.setRequestMethod("POST"); // PUT is another valid option
http.setDoOutput(true);
http.setRequestProperty("Authorization", "Basic " + encoding);
http.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
http.setRequestProperty("Accept", "application/json");
http.setRequestProperty("x-csrf-token", connection.getHeaderField("x-csrf-token"));
System.out.println(http.getHeaderFields());
我已经从GET
方法中检索了一个令牌,现在将其传递给POST
方法。
但是当我检查header
字段时,它为我提供了空白令牌。
这是我的GET
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "text/plain");
connection.setRequestProperty("Authorization", "Basic " + encoding);
connection.setRequestProperty("x-csrf-token", "fetch");
我对SetProperty
做错了吗?
x-csrf-token=[Required]