Author: Kellen Fields
Updated: December 2024
Audience: Self-hosted and Cloud-hosted customers
Summary
When using a PATCH REST API command to an empty field, you receive a bad request message back:
{
"meta": {
"status": "Bad Request",
"timestamp": "2024-04-07T17:51:18.034+0000",
"message": "no such path in target JSON document\n{\"op\":\"replace\",\"path\":\"/fields/method$89\",\"value\":\"test\"}"
}
}
And no update will take place.
Solution
If the field is empty, you cannot replace it using PATCH. Instead, you will have to use add:
{
"meta": {
"status": "OK",
"timestamp": "2024-04-07T17:53:20.841+0000"
}
}
Cause
According to RF 6902, which we use for available changes with PATCH (https://datatracker.ietf.org/doc/html/rfc6902#section-4.1), it states for add:
"If the target location specifies an object member that does not exist, a new member is added."
Whereas replace states:
"The "replace" operation replaces the value at the target location with a new value. The operation object MUST contain a "value" member whose content specifies the replacement value."
Related to
Comments
0 comments
Please sign in to leave a comment.