![](/img/trans.png)
[英]Web Service request is not working in android browser and code; but it is working in pc browser
[英]Different results back accessing the same php json request from android and pc web browser
I am having a problem where when I put the querying URL into a web browser on my Mac the API send the data back as I am expecting but when I use the exact same URL within my app on android I get the following error: {"SC":"400","VSM":"Incorrect parameter passed on URL","VERNUM":"1.2"}
。 這只是一個簡單的測試,看看我的應用程序中的數據庫是否是最新的。 這是 API 問題還是我在應用程序中做錯了什么? 我無法控制 API 功能,所以如果它有問題,那么我將不得不讓其他人來解決它。 我正在使用的代碼如下。
String URL = "http://Url.com/?p=api&request=check_for_changes";
Log.v("Value", URL);
JSONObject jsonObjSend = new JSONObject();
try
{
jsonObjSend.put("dataset_version_number", 1.1);
// Output the JSON object we're sending to Logcat:
Log.v("Response", jsonObjSend.toString(2));
}
catch (JSONException e)
{
Log.i("Response", "Error happened here");
}
try
{
jsonObjRecv = HttpClient.SendHttpPost(URL, jsonObjSend);
Log.v("SC", jsonObjRecv.get("SC").toString());
}
catch (JSONException e){
}
HttpClient
object 來自 class 我之前使用過很多次只是為了讀取來自服務器的響應,所以我不打算在這里發布代碼,因為它不相關而且很長。
答案的形式是我是個白痴,並試圖在不接受 JSON 且只需要GET
請求的 URL 上使用POST
請求。 所以我只需要查詢 URL 並獲得響應,而不是嘗試使用 JSON 通過POST
發送數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.