2016-07-28 10 views
0

Ich versuche, alle CREATED Geschäftspläne zu löschen:Faktur.plan Patch: HTTP 400 - Ungültige Pfad zur Verfügung gestellt

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); 
} 

aber alles, was ich bin immer ist:

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) 

Nach dem documentation Ich denke, ich mache es richtig. Allerdings habe ich versucht

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

usw. aber keiner von diesen funktioniert.

Was mache ich falsch?

Antwort

0

Nun, ich verwechselte die Dinge ein wenig. Die documentation sagt

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

und sie wirklich das bedeutet:

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

und natürlich macht es Sinn. Warum würden Sie den Pfad seit

plan.update(apiContext, patchRequestList); 

wird das für Sie schon tun. Ich denke, patch.setPath() ist hier, um einen zusätzlichen relativ Weg zu setzen.

Jetzt wissen Sie.