gpt4 book ai didi

java - 将 json 值发布到服务器的不同方法

转载 作者:行者123 更新时间:2023-11-29 21:09:37 25 4
gpt4 key购买 nike

i have created a login WCF service that is tested successfully using fiddler and postman tool..!

json post test

If the login process is success then WCF will give the json message as above screenshot. But when i posted username and password from android it gives the result as [{"message":"not created","success":-1}].i cant figure it out where the bug actually is.!! i am providing the corresponding android code and logcat below.please help me If the login process is success then WCF will give the json message as above screenshot.

But when i posted username and password from android it gives the result as [{"message":"not created","success":-1}].i cant figure it out where the bug actually is.!!

i am providing the corresponding android code and logcat below.please help me

If the login process is success then WCF will give the json message as above screenshot.

But when i posted username and password from android it gives the result as [{"message":"not created","success":-1}].i cant figure it out where the bug actually is.!!

i am providing the corresponding android code and logcat below.please help me

Logcat

below is webservice code in android

enter image description here

最佳答案

试试下面的代码:-

HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 60000);
HttpResponse response;

try
{

JSONObject j = new JSONObject();
j.put("UserName", "hiqmaali");
j.put("Password", "qwerty");
Messages.onLowmemory();
HttpPost post = new HttpPost(HOST_URL);

StringEntity stringEntity = new StringEntity(j.toString(), "UTF-8");
post.setEntity(stringEntity);

response = client.execute(post);

在您的情况下,将 json 发送到服务器,因此您必须尝试上述方式。

关于java - 将 json 值发布到服务器的不同方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23357335/

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