Updating Specific Array values within a content fragment using PUT call request | Community
Skip to main content
Level 2
March 5, 2024
Solved

Updating Specific Array values within a content fragment using PUT call request

  • March 5, 2024
  • 2 replies
  • 857 views

We have a multifield content fragment and we are using Assets HTTP API in order to update this content fragment.

 

We want to specifically update just the 2nd String from the list of multifield values but the PUT call request is expecting the entire request body.  Is there a way to just target the second value? Attached is the PUT call request for reference.

 

{
"properties": {
"cq:model": "/conf/infocus/settings/dam/cfm/models/testModel",
"name": "test",
"elements": {
"items": {
"value": [
"{\"value\":\"testPath\",\"key\":\"heroImagePath\"}",
"{\"value\":\"testPath\",\"key\":\"title\"}"
]
}
}
}
}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SureshDhulipudi

No, Assets HTTP API - using PUT - we have to send all values of an Asset.

 

Unfortunately, there's no way to directly update a single value in a set of values using the Assets HTTP API's PUT method. You must send the entire updated set of values in your PUT request.

2 replies

SureshDhulipudi
Community Advisor
Community Advisor
March 5, 2024

can you try get the existing / current values and update only 2nd value and send back all with PUT

 

  1. Make a GET request to get the current values of the multi-value property.
  2. Parse the response to extract the current values.
  3. Update the second value in the list of values.
  4. Make a PUT request to update the multi-value property with the new values.
sonalikuAuthor
Level 2
March 5, 2024

Thanks @sureshdhulipudi 

Is there a way to only do a specific second value update using the PUT call?

SureshDhulipudi
Community Advisor
SureshDhulipudiCommunity AdvisorAccepted solution
Community Advisor
March 6, 2024

No, Assets HTTP API - using PUT - we have to send all values of an Asset.

 

Unfortunately, there's no way to directly update a single value in a set of values using the Assets HTTP API's PUT method. You must send the entire updated set of values in your PUT request.