Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-IntersightPatchDocument json-patch remove operation not working with pointer #91

Open
briamorr opened this issue Mar 22, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@briamorr
Copy link

Describe the bug
Invoke-IntersightPatchDocument json-patch remove operation not working with pointer

According to https://intersight.com/apidocs/introduction/methods/#contenttype-applicationjsonpatchjson we should be able to reference values instead of the index:

"A more robust approach to delete the 'Owner' tag is to send the following PATCH request. This is more robust because the removal is independent of the element numerical index, which can help in the case of concurrent modifications for the same document.

PATCH https://intersight.com/api/v1/Server/Profiles/5a5f30237a6d67337212e705
Content-Type: application/json-patch+json
Body:
[
{ "op": "remove", "path": "/Tags[Key='Environment']" },
]"

To Reproduce
PS> $chassisprofile = Get-IntersightChassisProfile -Name 'IMM-FI-LOAN-2' -Organization $defaultorg

PS> $removetag = '[{ "op": "remove", "path": "/Tags[Key=''location'']" }]'

PS> $chassisprofile | Invoke-IntersightPatchDocument -JsonPatchDocument $removetag

Invoke-IntersightPatchDocument: The remote server returned an error: (400) Bad Request.
{"code":"InvalidRequest","message":"The HTTP 'PATCH' body failed validation. Error: error in remove for path: '/Tags[Key='location']': unable to remove nonexistent key: Tags[Key='location']: missing value","messageId":"barcelona_request_json_patch_validation_failed","messageParams":{"1":{}},"traceId":"K2REzRyJyz6kH26nqFxzJCSbGdLFrZ9_ROaQHhNGqOg097DTHQtO-w=="}

PS> $chassisprofile | Select-Object -Expand Tags

Key Value AdditionalProperties
env dev {}
location CA {}

Version used
1.0.11.7766
SaaS

Expected behavior
Being able to remove specific objects by value instead of index as specified in the API documentation

Additional context
Removal by index works fine only when trying to reference by value it fails

@Ghufz Ghufz added the bug Something isn't working label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants