Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法通过android中的HttpGet获取数据_Android_Json_Cakephp - Fatal编程技术网

无法通过android中的HttpGet获取数据

无法通过android中的HttpGet获取数据,android,json,cakephp,Android,Json,Cakephp,我试图使用以下url发送数据,但不知何故,它在Logcat中被声明为无效查询 Base_URI/users/add.json?json={“email”: xxx@x.com, “password”: “xxxxxxxxx”, “first_name”: “Xyz”, “last_name”: “Xyz”} 我以前问过这个问题,但没有找到解决办法,所以我现在更具体一些 据我所知,web服务是用cakephp制作的。它不接受url,因为这部分是“json={}”。此外,参数之间用“,”分隔,而不

我试图使用以下url发送数据,但不知何故,它在Logcat中被声明为无效查询

Base_URI/users/add.json?json={“email”: xxx@x.com, “password”: “xxxxxxxxx”, “first_name”: “Xyz”, “last_name”: “Xyz”}
我以前问过这个问题,但没有找到解决办法,所以我现在更具体一些

据我所知,web服务是用cakephp制作的。它不接受url,因为这部分是“json={}”。此外,参数之间用“,”分隔,而不是“&”。简而言之,我应该使用什么编码从中获取json

我在Logcat中得到这个错误:

Illegal character in query at index 56
还有一件事,除非在
org.apache.http
中没有解决方案,否则不对第三方库提出建议。顺便说一句,我试过截击库,但没有成功。

试试这个:

Base_URI/users/add.json?json={"email": "xxx@x.com", "password": "xxxxxxxxx","first_name": "Xyz", "last_name": "Xyz"}

经过一整天的调试和尝试不同的解决方案,我终于解决了自己的问题:)

我需要对参数部分进行编码,而不是对整个URL进行编码,如下所示:

String url = "Base_URI/users/add.json?json=";
    url =url +  URLEncoder.encode("{\"email\":\""+email+"\",\"password\":\""+password+"\"}", "UTF-8");

谢谢大家的参与

事实上,这与引号无关。我知道我在上面写错了。问题是别的