api - 为什么除了 Talend API tester 之外的每个客户端都可以使用此 REST 请求
问题描述
这是一个 REST POST 请求的示例,它可以在除 Talend API tester 之外的任何地方工作。它给出了 500 错误。
这是我在应用程序中设置请求的方式。
URLConnection connection = new URL("https://" + authHost + "/connect/token").openConnection();
logger.info("Connection oppened");
// message contains the form data: key=value&key=value&key=value
String message = "password=" + password + "&grant_type=password&username=" + username +
"&client_id=foolid&scope=mouthwash";
logger.info(message);
// Setting header fields.
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Accept", "application/json");
connection.getOutputStream().write(message.getBytes("UTF-8"));
这是 Postman 中的一个工作示例
POST /connect/token HTTP/1.1
Host: identityserver.uat.example.com
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Cookie: ARRAffinity=6a37d2ecf3441e27913cb832c4b767c68cad0e45c8806b3c5344d1b52d57f67a; ARRAffinitySameSite=6a37d2ecf3441e27913cb832c4b767c68cad0e45c8806b3c5344d1b52d57f67a
Content-Length: 137
password=secret&grant_type=password&username=fool&client_id=foolid&scope=mouthwash
这是 Talend 所说的它发送的内容,它得到了 500 错误——据我所知,它来自服务器。
POST /connect/token HTTP/1.1
Accept: application/json
Content-Length: 137
Content-Type: application/x-www-form-urlencoded
Host: identityserver.uat.example.com
password=secret&grant_type=password&username=fool&client_id=foolid&scope=mouthwash
这里发生了什么事?
解决方案
推荐阅读
- continuous-integration - Kubectl / Helm 等待所有资源被创建
- proxy - db2 作为代理的数据流
- html - 如何理解BR和IMG标签?
- powerbi - 在为 Power BI 配置报表服务器时,我无法通过数据库创建阶段
- javascript - 如何使用数组中的对象创建架构?猫鼬
- web - 在浏览器中播放 (H264 - MPEG4 - AVC) 直播流
- amazon-web-services - 我可以自定义通过 Slack 的 AWS Chatbot 集成接收的消息吗?
- python - /cart/ 处的 TypeError 无法解压不可迭代的 Cart 对象
- r - 在 R table1 包中使用自定义函数
- javascript - How to add a word per minute calculator to a website using Javascript, html, or css?