Replace element

Description

Use a HTTP POST request to replace a top level element from an array or key from an object in a resource. The request returns the updated resource.

Request

HTTP Method: POST

Parameter Description
resource_id The ID of the resource.
key The object key to replace if replacing from an object.
index The index of the element to replace if replacing from an array (with indexes starting at 0).
value The new value to replace the existing element with

Sample request

Sample request for an array element

curl -X POST \
  https://<<META.tenant.domain>>/api/v1/global_resources/<<resource_id>>/replace \
  -H 'content-type: application/json' \
  -H 'x-user-token: <<CREDENTIAL.tines_api_key>>' \
  -d '{
        "index": "0",
        "value": "new-value"
    }'

Sample request for an object key

curl -X POST \
  https://<<META.tenant.domain>>/api/v1/global_resources/<<resource_id>>/replace \
  -H 'content-type: application/json' \
  -H 'x-user-token: <<CREDENTIAL.tines_api_key>>' \
  -d '{
        "key": "foo",
        "value": "new-value"
    }'

Response

A successful request will return the updated resource value

Sample response

{ "foo": "new-value" }
Was this helpful?