我必须在帖子请求中发送给Web服务的示例输入
{
"Inputs": {
"input1": {
"Values": [
[
"12-12-2012",
"100",
"100",
"10",
"10",
"10",
"value"
]
]
}
}
}
从我来自服务的示例输出中,我只需要值,即75.7 ...
{
"Results": {
"output1": {
"type": "table",
"value": {
"ColumnNames": [
"Scored Label Mean"
],
"ColumnTypes": [
"Double"
],
"Values": [
[
"75.7329833331033"
]
]
}
}
}
}
我试图用截击来得到它,但我不知道如何在凌空的帮助下发送原始的json
我的代码是
JSONObject jsonObject = new JSONObject();
try {
JSONArray value = new JSONArray();
value.put("12-12-2012");
value.put("100");
value.put("100");
value.put("10");
value.put("10");
value.put("10");
value.put("value");
JSONArray Values = new JSONArray();
Values.put(value);
JSONObject Inputs = new JSONObject();
JSONObject input1 = new JSONObject();
input1.put("Values", Values);
Inputs.put("input1", input1);
jsonObject.put("Inputs", Inputs);
Log.d("check", "fetchDataFromServer:" + jsonObject);
} catch (JSONException e) {
e.printStackTrace();
}
JsonObjectRequest request = new JsonObjectRequest(
Request.Method.POST, URL_Helper.URL, jsonObject,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(MainActivity.this, "response", Toast.LENGTH_SHORT).show();
Log.d("123", "response:" + response.toString());
msgResponse.setText(response.toString());
progressDialog.cancel();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("123", "Error: " + error.getMessage());
progressDialog.cancel();
Toast.makeText(MainActivity.this, "error", Toast.LENGTH_SHORT).show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> map = new HashMap<>();
map.put("Authorization", "Bearer TFPAG2oT9sLWUK2FFwvxMm6ZKwRVBEaN7wyL5W5h3GRVgcn6K/uqRTlqRJpwgF9w==");
map.put("Content-Type", "application/json");
return map;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(request);
}
我收到了错误 E / Volley:[7113] BasicNetwork.performRequest:https://ussouthcentral.services.azure的意外响应代码400 ......