2016-07-28 4 views
0

내가 모든 CREATED 사업 계획 삭제하려고 해요 제공 :대금 청구 계획 패치 : - HTTP 400 잘못된 경로

for (Plan plan : created.getPlans()) { 

    List<Patch> patchRequestList = new ArrayList<>(); 

    Map<String, String> value = new HashMap<>(); 
    value.put("state", "DELETED"); 

    Patch patch = new Patch(); 
    patch.setPath("/v1/payments/billing-plans/" + plan.getId()); 
    patch.setValue(value); 
    patch.setOp("replace"); 

    patchRequestList.add(patch); 

    plan.update(apiContext, patchRequestList); 
} 

을하지만 내가 갖는 모든은 다음과 같습니다 documentation에 따르면

Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.sandbox.paypal.com/v1/payments/billing-plans/P-8SX60559PJ5455037EICJEYY 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422) 
    at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1889) 

나는 그것이 올바르게하고 있다고 생각한다. 그러나 나는 시도했다

patch.setPath("/v1/payments/billing-plans/" + plan.getId()); 
patch.setPath("/v1/payments/billing-plans"); 
patch.setPath("/payments/billing-plans); 

등등 그러나 이것들이 효과가 없다.

내가 뭘 잘못하고 있니?

답변

0

음, 약간 혼란 스러웠습니다. documentation

{ 
    "path": "/", 
    "value": { 
    "state": "ACTIVE" 
    }, 
    "op": "replace" 
} 

말한다 그들은 정말는 의미 :

Patch patch = new Patch(); 
patch.setPath("/"); 
patch.setValue(value); 
patch.setOp("replace"); 

을 물론 그것은 의미가 있습니다.

plan.update(apiContext, patchRequestList); 

이후로 경로를 설정하는 이유는 무엇입니까? 나는 patch.setPath()이 여기에 추가 상대 경로를 설정하는 것 같아요.

이제 알 수 있습니다.

관련 문제