Search in sources :

Example 21 with HttpRequest

use of cn.hutool.http.HttpRequest in project Jpom by dromara.

the class BuildTriggerTest method test.

@Test
public void test() {
    // 8cf594526db74f0eb79cac6da141c655/219a4009a0a68173d8d643d237f2ca8ad797d41dc5bcfceb83da4f4f1d1dbe933a1
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("id", "8cf594526db74f0eb79cac6da141c655");
    jsonObject.put("token", "219a4009a0a68173d8d643d237f2ca8ad797d41dc5bcfceb83da4f4f1d1dbe933a1");
    // 
    JSONArray jsonArray = new JSONArray();
    jsonArray.add(jsonObject);
    // 
    HttpRequest post = HttpUtil.createPost("http://127.0.0.1:2122/" + ServerOpenApi.BUILD_TRIGGER_BUILD_BATCH);
    post.body(jsonArray.toString(), MediaType.APPLICATION_JSON_VALUE);
    String body = post.execute().body();
    System.out.println(body);
}
Also used : HttpRequest(cn.hutool.http.HttpRequest) JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) Test(org.junit.jupiter.api.Test)

Aggregations

HttpRequest (cn.hutool.http.HttpRequest)21 Test (org.junit.Test)9 JSONObject (com.alibaba.fastjson.JSONObject)6 Ignore (org.junit.Ignore)5 HttpResponse (cn.hutool.http.HttpResponse)4 JpomRuntimeException (io.jpom.system.JpomRuntimeException)4 File (java.io.File)3 IOException (java.io.IOException)3 JsonMessage (cn.jiangzeyin.common.JsonMessage)2 JSONArray (com.alibaba.fastjson.JSONArray)2 Convert (cn.hutool.core.convert.Convert)1 FileUtil (cn.hutool.core.io.FileUtil)1 Tuple (cn.hutool.core.lang.Tuple)1 Validator (cn.hutool.core.lang.Validator)1 StrUtil (cn.hutool.core.util.StrUtil)1 URLUtil (cn.hutool.core.util.URLUtil)1 Entity (cn.hutool.db.Entity)1 Page (cn.hutool.db.Page)1 ServletUtil (cn.hutool.extra.servlet.ServletUtil)1 HttpUtil (cn.hutool.http.HttpUtil)1