It’s Cybersecurity Awareness Month! Join our interactive training session, or learn about security and AI from 1Password experts.
Forum Discussion
mmerrill
3 months agoNew Contributor
How to create an Address field type using the CLI?
I'm using the CLI to create an Identity item. The default Identity template has an example "ADDRESS" type, but fails to create an address with any value other than an empty string. I want to create the default address type not a STRING field.
Template Example Field Type:
{
"id": "address",
"section": {
"id": "address",
"label": "Address"
},
"type": "ADDRESS",
"label": "address",
"value": ""
}
JSON Copied from Identity Item:
{
"name": "address",
"title": "Address",
"fields": [
{
"k": "address",
"n": "address",
"t": "address",
"v": {
"city": "New York City",
"country": "us",
"state": "New York",
"street": "123 4th Street",
"zip": "12345"
}
}
]
}
The error when you pass in a non-empty string is:
'[ERROR] validateVaultItem failed to Validate: Couldn't validate the item: "[ItemValidator] has found 1 errors, 0 warnings: \\nErrors:{1. details.sections[1].fields[0].v has invalid type: \\"string\\". Requires one of [object] value}"\n'
The error when you pass in an object is:
'[ERROR] invalid JSON template: json: cannot unmarshal object into Go struct field ItemField.fields.value of type string\n'
How do you create an address if not a string or an object?
2 Replies
- 1P_Phil
Moderator
Hi mmerrill ,
I just wanted to drop a note and let you know i'm looking into this. I've also requested an update to the "op item get template" command to include examples for objects like this so you don't have to dig as much.
I hope to hear back from the team in the next day or so.
Thanks in advance for your patience,
Phil- 1P_Phil
Moderator
Hi mmerrill ,
Just to confirm address are supported by the CLI, but the actual value of the address is a string (due to localization). Here is an example you can use to get it working.
You'll see what I mean in line 9 "value"
{ "id": "address", "section": { "id": "address", "label": "Address" }, "type": "ADDRESS", "label": "address", "value": "Street Address 123, 1234XY, Delft, Netherlands", "reference": "op://acceptance-tests/test-identity/Address/address" },
Thanks,
Phil