0
我有一个简单的测试,在测试中,如果json的POST成功。这是我的测试:POST JSON okhttp
int expectedCodeResponse = 201;
Map<String, String> params = new HashMap<String, String>();
params.put("batchPublicId", "001");
params.put("fileSize", "2");
params.put("location", "{\\\"bucket\\\":\\\"blabla\\\"}");
params.put("title", "testInvoice");
JSONObject parameter = new JSONObject(params);
OkHttpClient httpClient = new OkHttpClient();
RequestBody body = RequestBody.create(JSON, parameter.toString());
Request request = new Request.Builder()
.url(environmentUrls.get("base_url") + "/invoices")
.post(body)
.addHeader("content-type", "application/json; charset=utf-8")
.build();
Response response = httpClient.newCall(request).execute();
Assert.assertEquals(response.code(), expectedCodeResponse);
现在它不再工作,因为fileSize不是一个字符串了,它是一个int。我该如何解决这个问题?