可以在HttpHeader中设置“application/x-www-form-urlencoded”,但我想在requestbody中设置,请指导我?
json示例:
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "Tohid",
"type": "text"
},
{
"key": "password",
"value": "*mk",
"type": "text"
},
{
"key": "grant_type",
"value": "password",
"type": "text"
}
]
},
字符串
代码:
HttpHeaders headers = new HttpHeaders();
headers.add(MediaType.APPLICATION_JSON, APPLICATION_URLENCODED.getValue());
HttpEntity<?> requestEntity = new HttpEntity<>(gson.toJson(requestBody), headers);
型
Postman 截图:x1c 0d1x的数据
1条答案
按热度按时间yhxst69z1#
最后,我发现在“application/x-www-form-urlencoded”中,我们必须使用以下内容:
字符串