# What is correct PATCH request structure to update a specific attributevalue of an organisationUnit

**URL:** <https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754>\
**Category:** Development - Développement\
**Tags:** api\
**Created:** [5 June 2025 08:24 UTC](https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754 "2025-06-05T08:24:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arslan\_mughal](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/arslan_mughal/32/46857_2.png) [@arslan\_mughal](https://community.dhis2.org/u/arslan_mughal)\
**Post date:** [5 June 2025 08:24 UTC](https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754/1 "2025-06-05T08:24:53Z")

</div>

Hi Community,  
What is the correct PATCH request structure to update a specific attributevalue of an `organisationUnit` via the `../api/organisationUnits/{id}` endpoint?  
(I want to update only specifc attributevalue (Custom Attribute) rest should stay “as it is” in metadata.(instead of full PUT Request))  
Version 2.40.6  
[Partial Updates](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-242/metadata.html#webapi_partial_updates).  
Any working examples would be appreciated!

---

<div class="post-metadata">

**Author:** ![Gassim](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gassim/32/35347_2.png) [@Gassim](https://community.dhis2.org/u/Gassim)\
**Post date:** [6 June 2025 08:05 UTC](https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754/2 "2025-06-06T08:05:43Z")

</div>

Hi @arslan_mughal

Could you please share the JSON that includes your custom attribute?

For this case you will use PATCH /api/organisationUnits/{id} as you explained and the payload patch will be (based on the [https://jsonpatch.com/](https://jsonpatch.com/) instructions)

```auto
[
  { "op": "replace", "path": "pathtothecustomattribute", "value": "newValue" }
]

```

---

<div class="post-metadata">

**Author:** ![arslan\_mughal](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/arslan_mughal/32/46857_2.png) [@arslan\_mughal](https://community.dhis2.org/u/arslan_mughal)\
**Post date:** [6 June 2025 11:28 UTC](https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754/3 "2025-06-06T11:28:08Z")

</div>

Payload:  
json

```auto
[
  {
    "op": "replace",
    "path": "/attributeValues/attribute/id/qyY5ZVWvpBr/value",
    "value": "newCode123"
  }
]

```

I also tried:

```auto
[
  {
    "op": "replace",
    "path": "/attributeValues/qyY5ZVWvpBr/value",
    "value": "newCode123"
  }
]

```

But got the error:  
Payload cannot contain objects or arrays. ErrorCode: E1003  
Also tried without [] square brackets and response is `1` but value not updated.  
with PATCH ../api/organisationUnits/{id}

Error Response is :

```auto
{
    "httpStatus": "Bad Request",
    "httpStatusCode": 400,
    "status": "ERROR",
    "message": "Payload can not contain objects or arrays.",
    "errorCode": "E1003"
}

```

---

<div class="post-metadata">

**Author:** ![tzemp](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/tzemp/32/36236_2.png) [@tzemp](https://community.dhis2.org/u/tzemp)\
**Post date:** [20 June 2025 09:36 UTC](https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754/4 "2025-06-20T09:36:35Z")

</div>

Hi @arslan_mughal. I hope you have figured out your question by now, but if you still are looking into this, you need to patch the entire array of attribute values when making an update.

E.g.  
`[{"op":"replace","path":"/attributeValues","value":[{"attribute":{"id":"UKNKz1H10EE"},"value":"test"}]}]`

You can also look at the new Maintenance Preview app (available via App Management App if it is not already installed). There you can edit an organisation unit, update an attribute value, and then look at the networks tab to inspect the payload

---

<div class="post-metadata">

**Author:** ![arslan\_mughal](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/arslan_mughal/32/46857_2.png) [@arslan\_mughal](https://community.dhis2.org/u/arslan_mughal)\
**Post date:** [21 June 2025 09:30 UTC](https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754/5 "2025-06-21T09:30:15Z")

</div>

You are right the correct payload is:

```auto
[
  {
    "op": "replace",
    "path": "/attributeValues",
    "value": [
      {
        "attribute": {
          "valueType": "TEXT",
          "mandatory": false,
          "id": "qyY5ZVWvpBr"
        },
        "value": "mynewvalue"
      }
    ]
  }
]

```

This works for PATCH requests, but only if you set the Content-Type header to -\>application/json-patch+json Without that, the server will reject it. Just wanted to clarify that in case anyone else runs into the same issue. Thanks!

---

<div class="post-metadata">

**Author:** ![Gassim](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gassim/32/35347_2.png) [@Gassim](https://community.dhis2.org/u/Gassim)\
**Post date:** [23 June 2025 10:12 UTC](https://community.dhis2.org/t/what-is-correct-patch-request-structure-to-update-a-specific-attributevalue-of-an-organisationunit/65754/6 "2025-06-23T10:12:03Z")

</div>

That’s great! Thanks for sharing the solution. 🙂
