Forum Discussion
Unable to add item url label via API
I successfully created new items via the API directly as well as Ansible, however when I'm adding "url"s to an "item" I'm not able to set / get / change the label of the URL item, whereas the client and web UI provides this possibility.
I'm not sure where to file this feature request, but somehow either the URL object or the item create function could be extended to support this.
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
3 Replies
- Former Member
The issue is reproducible. Here is a Vagrantfile that will reproduce the issue:
```
To replicate the issue with running the
op
command directly from a Golang appVagrant.configure("2") do |config|
config.vm.box = "generic/fedora37"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "2048"
vb.cpus = "2"
vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
end
config.vm.provision "shell", privileged: false, inline: <<~'EOF'
#!/usr/bin/env bashset -x sudo dnf update -y sudo dnf group install -y "Fedora Workstation" --allowerasing sudo systemctl enable gdm.service sudo systemctl set-default graphical.target sudo dnf install -y golang sudo rpm --import https://downloads.1password.com/linux/keys/1password.asc sudo sh -c 'echo -e "[1password]\nname=1Password Stable Channel\nbaseurl=https://downloads.1password.com/linux/rpm/stable/\$basearch\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=\"https://downloads.1password.com/linux/keys/1password.asc\"" > /etc/yum.repos.d/1password.repo' sudo dnf install -y 1password 1password-cli echo ' package main import ( "log" "os/exec" "os" "fmt" ) func main() { fmt.Println(os.Args) var opExecutable string if os.Args[1] == "python" { opExecutable = "./op.py" } else if os.Args[1] == "direct" { opExecutable = "op" } op := exec.Command(opExecutable, "item", "list") out, err := op.Output() if e, ok := err.(*exec.ExitError); ok { log.Fatal(e, ": ", string(e.Stderr)) } println(string(out)) } ' > ~/main.go echo '#!/usr/bin/env python3 import subprocess import sys subprocess.run(["op"] + sys.argv[1:]) ' > ~/op.py chmod +x ~/op.py set +x echo "Now reboot the VM with 'vagrant reload'. Once that is done, log into the VM when it loads (password is 'vagrant'), sign into 1Password" echo "and configure it to allow connection from the CLI. Then, from the terminal in the VM, run 'op signin'." echo "To replicate the issue, run 'go run main.go direct'. To run it though Python, run 'go run main.go python'."
EOF
end
``` - Former Member
Interestingly enough, when I call the Python script from the Go app, it works fine. Given the following Python script named
op.py
:```
!/usr/bin/env python
import subprocess
subprocess.run(["op", "item", "get", "DocSend", "--format=json"])
```and the following Go app in the same directory:
```
package mainimport (
"encoding/json"
"fmt"
"log"
"os/exec"
)func main() {
op := exec.Command("/usr/bin/python3.11", "./op.py")
//op := exec.Command("op", "item", "get", "DocSend", "--format=json")
out, err := op.Output()
if e, ok := err.(*exec.ExitError); ok {
log.Fatal(e, ": ", string(e.Stderr))
}fmt.Printf("%s", out) var item map[string]interface{} if err := json.Unmarshal(out, &item); err != nil { log.Fatal(err) } fmt.Println(item["fields"])
}
```...it works fine, the output gets printed. I can test that it is being printed by the Go app and not by the Python script because if I remove the
fmt.Printf(...)
and below, nothing gets printed.