【发布时间】:2017-10-03 08:00:05
【问题描述】:
我想使用 POST METHOD
将此 json 正文发送到服务器 {
"donatations": [
{
"campaignId": "string",
"name": "string",
"type": 0,
"donationValue": 0
}
],
"profileId": "string",
"creditCardId": "string",
"isPaidFees": true,
"isRequestDonatation": true
"amountFees": 0,
"totalDonationAmount": 0,
"institutionId": "string"
}
我尝试了许多网络上可用的解决方案,但大多数都告诉格式化字符串并发送到服务器。是否有任何正确的方法可以将此正文发送到服务器?
我通常这样做是为了向服务器发送简单的字符串
JsonObject dados = new JsonObject();
dados.addProperty("profileId", sessionManager.getUsuario().getId());
dados.addProperty("name", scanResult.cardholderName.toString());
并将 JsonObject 作为我的 POST 的正文发送
请帮助我。谢谢。
【问题讨论】:
-
您需要从有效的 JSON 开始。此外,向我们展示您创建的不起作用的代码,解释究竟什么不起作用,也许我们可以帮助解决它。
标签: android