Forum Discussion

Anonymous's avatar
Anonymous
5 years ago

add a field via PATCH

I'm trying to add a new field to an item via PATCH

As I understand from the RFC https://datatracker.ietf.org/doc/html/rfc6901 I can pass something like

```
{
"path": "/fields/4",
"op": "add",
"value": {
"label": "pkcs12base64",
"type": "STRING",
"value": "MIIRuQIB...."
}
}

```

and I will find a new field at position 4 if I have 4 fields already there

I receive a 400 Invalid request body or parameter

How should it be done instead?

Thanks


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided

1 Reply

  • Anonymous's avatar
    Anonymous

    Hi there,

    You should be able to add a new field with the following:
    [
    {
    "op": "add",
    "path": "/fields",
    "value": {
    "label": "pkcs12base64",
    "type": "string",
    "value": "MIIRuQIB...."
    }
    }
    ]

    Note that you do not need to include a position number for the new field. See https://support.1password.com/connect-api-reference/#change-item-details for more information on performing patch operations. You can also view the api spec https://github.com/1Password/connect/blob/main/docs/openapi/spec.yaml for more examples.