06-10-2016 10:07 AM - edited 03-01-2019 04:28 AM
Hello! I'm trying to use the APIC-EM and its API to update a policy, but I get the error "BadRequest", with failureReason "Invalid Policy". The body I'm using in the PUT request is the following json:
"instanceUuid":"a298dfd7-1a21-4ab5-a223-df415906a681",
"policyName":"Test-Policy-1_BR",
"policyOwner":"devnetuser",
"policyPriority":4095,
"state":"Active",
"taskId":"f3a40f1d-a675-4cb8-acec-41b0625ac161",
"id":"96348dc5-a760-4ce3-9ee8-28b349ba6618",
"appName":"ptp",
"id":"0661d06e-99ad-41b6-93e0-e36ff02029af"
},
"appName":"twitch-tv",
"id":"019d6ce9-8e40-401c-9b11-14483d7d5f7d"
},
"appName":"distcc",
"id":"01b823bd-9a18-4891-8eed-8d40c2016abe"
},
"appName":"directv-soft",
"id":"012ac649-a306-4c0c-9098-da00bc91d510"
},
"appName":"windows-store",
"id":"00d2d0d4-1b31-43ff-845e-f4f1f0fd7b07"
}
]
},
"SET_PROPERTY"
],
"policyScope":"Test-Policy-1",
"relevanceLevel":"Business-Rrelevant",
"pathControlFlag":false,
"pathPreferenceFlag":false
}
}
]
The json I'm getting as processing the task is this one:
"startTime":1465576395397,
"endTime":1465576395403,
"progress":"Policy Update Failed",
"version":1465576395397,
"errorCode":"BadRequest",
"serviceType":"Policy Service",
"669ea643-04ad-478e-abe9-322dc775e872"
],
"isError":true,
"failureReason":"Invalid Policy",
"rootId":"30e589a3-613c-4184-a681-6378cd201de0",
"id":"30e589a3-613c-4184-a681-6378cd201de0"
},
"version":"1.0"
}
Also, while trying to update a policy with this body:
[
{
"instanceUuid":"a298dfd7-1a21-4ab5-a223-df415906a681",
"policyName":"Test-Policy-1_IR",
"policyOwner":"devnetuser",
"policyPriority":4095,
"state":"Active",
"taskId":"9f3f7ece-10e8-4e9b-9476-c96b8280d343",
"id":"a298dfd7-1a21-4ab5-a223-df415906a681",
"resource":{
"applications":[
{
"appName":"wordreference-com",
"id":"218c7242-9455-42b8-aaf9-5e65f7a322ca"
},
{
"appName":"smakynet",
"id":"04fa6934-6e42-496a-93e6-1f5e4ccb464d"
}
]
},
"actions":[
"SET_PROPERTY"
],
"policyScope":"Test-Policy-1",
"actionProperty":{
"relevanceLevel":"Business-Irrelevant",
"pathControlFlag":false,
"pathPreferenceFlag":false
}
}
]
I get this response:
"startTime":1465577653334,
"endTime":1465577653415,
"progress":"Policy Update Failed",
"version":1465577653334,
"errorCode":"ResourceConflict",
"serviceType":"Policy Service",
"360966c9-0306-47b9-94c8-7972e39f13e0"
],
"isError":true,
"failureReason":"Policy Conflict",
"rootId":"9eadc2d0-0eaf-4da0-92a6-71f86110ee20",
"id":"9eadc2d0-0eaf-4da0-92a6-71f86110ee20"
},
"version":"1.0"
}, having errorCode "ResourceConflict" and failureReason "Policy Conflict".
Any ideas what those errors mean?
06-13-2016 11:47 AM
Are you doing this from your network or Cisco DevNet Sandbox ?
06-13-2016 11:49 AM
I'm trying to update the policy from the Cisco DevNet Sandbox.
06-13-2016 03:07 PM
Cisco DevNet Sandbox Always On or reserved ?
Your POST policy has no error tight ? Can you please share your JSON for POST ?
You know that Always On Lab is using Data Base, not really connect to live network right ? So we can create a policy but cannot really activate the policy.
06-13-2016 03:25 PM
I think it's not reserved and yes, I know that. I just want to demonstrate how you can create and update policies. This is the POST json:
"policyName":"Test-Policy_D",
"policyOwner":"devnetuser",
"policyPriority":4095,
"appName":"avian",
"id":"05bafa0b-63ab-4a73-9a95-0a12cf9156cd"
}
]
},
"SET_PROPERTY"
],
"policyScope":"Test-Policy",
"relevanceLevel":"Default"
}
}
]
06-14-2016 12:00 PM
Works fine with me
first I use get policy and select "Test-Policy" from existing policy to modify
the response from "GET policy"
{
"instanceUuid": "1321f81e-acda-4830-8882-f434ace91231",
"policyPriority": 4095,
"policyName": "Test-Policy_BR",
"actionProperty": {
"pathPreferenceFlag": false,
"relevanceLevel": "Business-Relevant",
"pathControlFlag": false
},
"actions": [
"SET_PROPERTY"
],
"state": "Active",
"policyScope": "Test-Policy",
"taskId": "47b1e3e9-4b6e-423a-b007-3230b5f8a36d",
"id": "1321f81e-acda-4830-8882-f434ace91231",
"policyOwner": "devnetuser",
"resource": {
"applications": [
{
"appName": "twitch-tv",
"id": "019d6ce9-8e40-401c-9b11-14483d7d5f7d"
},
{
"appName": "sntp-heartbeat",
"id": "02d81471-2c4f-497d-b000-f6ae3e32c96f"
}
]
}
}
I just change "policyPriority": 4095 to "policyPriority": 4099 so here is my JSON
[{
"id": "1321f81e-acda-4830-8882-f434ace91231",
"policyPriority": 4999,
"policyName": "Test-Policy_BR",
"actionProperty": {
"relevanceLevel": "Business-Relevant",
},
"actions": [
"SET_PROPERTY"
],
"state": "Active",
"policyScope": "Test-Policy",
"policyOwner": "devnetuser",
"resource": {
"applications": [
{
"appName": "twitch-tv",
"id": "019d6ce9-8e40-401c-9b11-14483d7d5f7d"
},
{
"appName": "sntp-heartbeat",
"id": "02d81471-2c4f-497d-b000-f6ae3e32c96f"
}
]
}
}]
Here is the result of PUT task, no error.
{ |
"response": {
"startTime": 1465930102747, | |
"endTime": 1465930102955, | |
"version": 1465930102747, | |
"serviceType": "Policy Service", | |
"operationIdList": [ | |
"49a4da31-3649-4746-95e7-19f583a21656" | |
], | |
"isError": false, | |
"rootId": "632eefa4-7754-43ad-be94-b7bb97c647cb", | |
"id": "632eefa4-7754-43ad-be94-b7bb97c647cb" |
},
"version": "1.0"
}
The I did the GET policy again. From the response we can see the policyPriority changed to 4999
{
"actions": [
"SET_PROPERTY"
],
"state": "Active",
"policyOwner": "devnetuser",
"resource": {
"applications": [
{
"appName": "twitch-tv",
"id": "019d6ce9-8e40-401c-9b11-14483d7d5f7d"
},
{
"appName": "sntp-heartbeat",
"id": "02d81471-2c4f-497d-b000-f6ae3e32c96f"
}
]
},
"instanceUuid": "1321f81e-acda-4830-8882-f434ace91231",
"taskId": "632eefa4-7754-43ad-be94-b7bb97c647cb",
"actionProperty": {
"relevanceLevel": "Business-Relevant",
"pathPreferenceFlag": false,
"pathControlFlag": false
},
"id": "1321f81e-acda-4830-8882-f434ace91231",
"policyName": "Test-Policy_BR",
"policyPriority": 4999,
"policyScope": "Test-Policy"
}
06-19-2016 06:20 AM
It's still the same for me.. Sometimes it works, sometimes I get "Invalid Policy" as an answer and sometimes it's "Policy Conflict" as failureReason. What should I do?
06-19-2016 02:58 PM
Policy Conflict may due to duplicate of policy name or something else. I think "Invalid Policy" is a little bit more difficult to find the reason. Sometime I got this that "I think" APIC-EM doesn't like the JSON object. It will be nice if APIC-EM can point out where it went wrong.
"Sometime it works, sometime not", were you using the same JSON or different JSON to try ?
BTW which version of Sandbox you're using ? 1.1 - sandboxapic.cisco.com:9443 ? or 1.2 - sandboxapic.cisco.com ?
06-20-2016 12:02 PM
Yes I think it's hard to find the reason too! I'm using Sandbox version 1.2 and I'm developing a demo app that uses the APIC-EM api. It works fine if I POST a policy and update it (for example the Business Irrelevant part of the policy). It still works if I POST another policy (for example, the Business Relevant part of the policy) and update. But if I switch back to the first policy and try to update it, it doesn't work anymore. The code should work, it doesn't have a problem.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide