private void sendData(int id) throws JSONException {
RequestQueue queue = Volley.newRequestQueue(this);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
String format = simpleDateFormat.format(new Date());
JSONObject jsonData = new JSONObject();
jsonData.put("stationId", id);
jsonData.put("patientId", Integer.parseInt(values.getID()));
jsonData.put("timestamp", format);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, postUrl + "/stations/signin", jsonData, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=utf-8");
headers.put("Accept", "*/*");
return headers;
}
};
queue.add(jsonObjectRequest);
}
我正在尝试将json发送到服务器,以接收响应代码,例如:(200)int。 我该如何解决这个错误?
-编辑:添加了其余代码-