使用com.sun.jersey.api.client.Client,ClientResponse和WebResource。
Client client = this.client;
WebResource webResource = null;
ClientResponse response = null;
String url = "";
url =“ https://test.com/rest/V1/cart/” + quoteId +“ / items”;
webResource = client.resource(url);
String jsonString = "{\"cartItem\":{\"quote_id\":" + quoteId + ",\"id\": " + id+ ",\"qty\":" + qty + "}}";
ObjectMapper mapper = new ObjectMapper();
JsonFactory factory = mapper.getFactory();
JsonParser parser = factory.createParser(jsonString);
JsonNode actualObj = mapper.readTree(parser);
response = webResource.header("Authorization", "Bearer " + this.token).type("application/json")
.post(ClientResponse.class, actualObj);
我有错误
索引52处路径中的非法字符:https://test.com/rest/V1/cart/“ IerwexsKLchKYmZ1ryKZkor9RdfJ2Dp3” /项目
我正在将quoteId作为参数String quoteId="IerwexsKLchKYmZ1ryKZkor9RdfJ2Dp3";
如何从URL中删除quoteId的引号? 谢谢。