Can I use curl update my 1password items with api connect server ?

Hi ,
I built an API connecting server, it looks like my connecting server works as expected and I'm able to get my item details by curl successfully

/usr/local # curl -H "Authorization: Bearer ${ONEPASSWORD_TOKEN}" -H "Content-Type: application/json" \

{
"id": "",
"title": "My Key - base64",
"version": 60,
"vault": {
"id": ""
},
"category": "SECURE_NOTE",
"lastEditedBy": "H5JL3QWPHVBLJJERL6Y7PRZMFQ",
"createdAt": "2021-10-11T08:48:47Z",
"updatedAt": "2021-10-26T08:31:12Z",
"sections": [
{
"id": "add more"
},
{
"id": "linked items",
"label": "Related Items"
}
],
"fields": [
{
"id": "notesPlain",
"type": "STRING",
"purpose": "NOTES",
"label": "notesPlain",
"value": "mytest"
}
]
}

Then I tried to update my items by using PUT method , yet it failed and gave me the following error message

    {"status":400,"message":"Invalid request body or parameter"}

My command used is
curl -H "Authorization: Bearer ${ONEPASSWORD_TOKEN}" -H "Content-Type: application/json" -X PUT -d @key.json \
http://onepassword-connect.onepassword.svc.cluster.local:8080/v1/vaults/${OP_VAULT_ID}/items/${OP_PUBLIC_ITEM_ID}

key.json
{
"id": "",
"title": "My Key - base64",
"version": 60,
"vault": {
"id": ""
},
"category": "SECURE_NOTE",
"lastEditedBy": "H5JL3QWPHVBLJJERL6Y7PRZMFQ",
"createdAt": "2021-10-11T08:48:47Z",
"updatedAt": "2021-10-26T08:31:12Z",
"sections": [
{
"id": "add more"
},
{
"id": "linked items",
"label": "Related Items"
}
],
"fields": [
{
"id": "notesPlain",
"type": "STRING",
"purpose": "NOTES",
"label": "notesPlain",
"value": "mytest---------------------------------mytest"
}
]
}

I tried to used PATCH method, it failed as well with the same error

 {"status":400,"message":"Invalid request body or parameter"} 

My command used is :
curl -H "Authorization: Bearer ${ONEPASSWORD_TOKEN}" -H "Content-Type: application/json" -X PATCH -d @patch.json \
http://onepassword-connect.onepassword.svc.cluster.local:8080/v1/vaults/${OP_VAULT_ID}/items/${OP_PUBLIC_ITEM_ID}

patch.json
'{ "op": "replace", "path": "/title", "value": "My New TITLE" }'

My helm chart is 1.7.0 ,my app version is 1.5.0

I did some search and got https://1password.community/discussion/120695/adding-an-element-using-the-api, yet I still don't know how to edit my code , Can anyone help here ? thanks


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

Comments

  • Anyone knows what's wrong here ? thx

  • this issue was fixed . there was a line break in my api token . I removed the line break , everything works as expected . Thx

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file