每次收到错误" BAD请求"。我试图发布像这样的json
的数据{
"name":"testOne",
"location": "['one','two','three']"
}
这是我的代码
AsyncHttpClient client = new AsyncHttpClient();
String someData="{\"name\":\"testOne\",\"location\": \"['ne','two','three']\"}";
ByteArrayEntity be = new ByteArrayEntity(someData.toString().getBytes());
client.post(MainActivity.this, "http://impero-dannyfast.rhcloud.com/api/agents", be, "application/json", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
Toast.makeText(MainActivity.this, "Succ", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
Toast.makeText(MainActivity.this, "fail"+statusCode, Toast.LENGTH_SHORT).show();
}
});
答案 0 :(得分:0)
查看这些教程,您将得到答案https://www.youtube.com/watch?v=frltqnSKqiA&list=PLgjt1h_kabFebUn1anGYZ6_Tfkw64Ww12&index=11
答案 1 :(得分:0)
{
"name":"testOne",
"location": ["one","two","three"]
}
尝试像这样发送