I think the issue may be related to MS-DOS command line, as the error appears to be persisting only when I run bw commands in that shell.
When I use powershell, it works fine.
I have only just started with this, so if anyone with more expreience could give me some tips, I would appreciate it. Maybe there is a better, shorter way to accomplish the same? Also, at this time I cannot use this script for automation, as I need to manually add the password, when prompted. Is there any way to handle this better?
Thanks!
Here are the scripts that I tested:
PowerShell
PS C:\Users\ph>$item_id = bw list items --search "goodexample" | jq -r '.[0].id'
? Master password: [hidden]
PS C:\Users\ph>bw get item $item_id > goodexample.json
? Master password: [hidden]
PS C:\Users\ph>$jsonContent = Get-Content -Raw -Path goodexample.json | ConvertFrom-Json
PS C:\Users\ph>$jsonContent.login.password = "thisistheworstone"
PS C:\Users\ph>$jsonContent | ConvertTo-Json -Depth 10 | Set-Content -Path goodexample.json
PS C:\Users\ph>$encodedJson = echo (Get-Content -Raw -Path goodexample.json) | bw encode
PS C:\Users\ph>bw edit item $item_id $encodedJson
? Master password: [hidden]
{"passwordHistory":[{"lastUsedDate":"2025-01-01T17:50:55.367Z","password":"bestpwdever"}],"revisionDate":"2025-01-01T17:50:53.917Z","creationDate":"2025-01-01T11:56:48.990Z","deletedDate":null,"object":"item","id":"0d204273-5f35-4147-orite":false,"login":{"fido2Credentials":[],"uris":[{"match":null,"uri":"good-prob-01"}],"username":"gooduser","passw
PS C:\Users\ph>bw get item $item_id
? Master password: [hidden]
17:50:53.917Z","creationDate":"2025-01-01T11:56:48.990Z","deletedDate":null,"object":"item","id":"0d204273-5f35-4147-b482-b25800c4e13c","organizationId":null,"folderId":null,"type":1,"reprompt":0,"name":"goodexample","notes":null,"favord":"thisistheworstone","totp":null,"passwordRevisionDate":"2025-01-01T17:50:55.367Z"},"collectionIds":[]}
PS C:\Users\ph>
MS-DOS:
C:\Users\ph>bw get item %item_id% > goodexample.json
? Master password: [hidden]
C:\Users\ph>jq ".login.password = \"thisistheworstoneyet\"" goodexample.json > updated_goodexample.json
C:\Users\ph>bw encode < updated_goodexample.json > encoded.json
C:\Users\ph>bw edit item %item_id% encoded.json
? Master password: [hidden]
Error parsing the encoded request data.
C:\Users\ph>type updated_goodexample.json
{
"passwordHistory": [
{
"lastUsedDate": "2025-01-01T18:02:42.315Z",
"password": "thisistheworstone"
},
{
"lastUsedDate": "2025-01-01T17:50:55.367Z",
"password": "bestpwdever"
}
],
"revisionDate": "2025-01-01T18:02:40.876Z",
"creationDate": "2025-01-01T11:56:48.990Z",
"deletedDate": null,
"object": "item",
"id": "0d204273-5f35-4147-b482-b25800c4e13c",
"organizationId": null,
"folderId": null,
"type": 1,
"reprompt": 0,
"name": "goodexample",
"notes": null,
"favorite": false,
"login": {
"fido2Credentials": [],
"uris": [
{
"match": null,
"uri": "good-prob-01"
}
],
"username": "gooduser",
"password": "thisistheworstoneyet",
"totp": null,
"passwordRevisionDate": "2025-01-01T18:02:42.315Z"
},
"collectionIds": []
}
C:\Users\ph>