计费计划补丁:HTTP 400 - 提供的路径无效
Billing plan patch: HTTP 400 - Invalid Path provided
我正在尝试删除所有 CREATED
商业计划:
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);
}
但我得到的是:
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.run(HttpURLConnection.java:1889)
根据 documentation,我认为我做的是正确的。不过,我试过了
patch.setPath("/v1/payments/billing-plans/" + plan.getId());
patch.setPath("/v1/payments/billing-plans");
patch.setPath("/payments/billing-plans);
等但其中 none 有效。
我做错了什么?
好吧,我有点糊涂了。 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()
是在这里设置一个额外的 relative 路径。
现在你知道了。
我正在尝试删除所有 CREATED
商业计划:
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);
}
但我得到的是:
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.run(HttpURLConnection.java:1889)
根据 documentation,我认为我做的是正确的。不过,我试过了
patch.setPath("/v1/payments/billing-plans/" + plan.getId());
patch.setPath("/v1/payments/billing-plans");
patch.setPath("/payments/billing-plans);
等但其中 none 有效。
我做错了什么?
好吧,我有点糊涂了。 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()
是在这里设置一个额外的 relative 路径。
现在你知道了。