gpt4 book ai didi

Java 泽西客户端 API

转载 作者:行者123 更新时间:2023-12-01 15:14:27 24 4
gpt4 key购买 nike

我是 Java Jersey Client API 的新手,想要登录服务器,例如:

POST http:/xxxx.net/auth/login

Content-Type: application/json
{"login": "xxxxx", "password": "XXXXX"}

您能给我看一个这样的 Java Jersey 客户端 API 代码的示例吗?

最佳答案

// create a Jersey client
Client client = Client.create();

// create the JSON as a Map
Map<String, String> data = new HashMap<String, String>();
data.put("login", "xxxxx");
data.put("password", "xxxxx");

// post to the resource with APPLICATION_JSON_TYPE and it will be converted to JSON for you
client.resource("http://xxxx.net/auth/login")
.type(MediaType.APPLICATION_JSON_TYPE)
.post(data);

关于Java 泽西客户端 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11828031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com