It’s Cybersecurity Awareness Month! Join our interactive training session, or learn about security and AI from 1Password experts.
Forum Discussion
Former Member
4 years agoFailed to create item: invalid JSON
Hi Team,
We've been using the 1Password CLI for quite some time, but are now trying to switch to CLIv2
In doing that, we've discovered some really odd behaviour, making it impossible for us to cr...
Former Member
4 years agoHey @corevo,
I was able to debug this with one of my colleagues who has encountered this problem themselves, using a JavaScript wrapper for the CLI (many thanks to @"jody.h_1P" for the help).
Indeed, there seems to be a bug that we have an internal ticket already tracking. In certain environments, it seems that the CLI interprets a programatic call as receiving piped input when it's not present, in fact.
We'll continue tracking this, and will update the thread when it is resolved. As a workaround, in the meantime, switching some of the input to be piped should help with the problem, before a fix is released:
```
import { execa } from 'execa'
const result = await execa(
echo "${JSON.stringify({ title: "title" }).replace(/"/g, '\\"')}" | op
,
[
'item',
'create',
'-',
'--category=Password',
'--generate-password=letters,digits,symbols,32',
'--format=json'
],
{
shell: true
}
);
```
Let us know if this helps.
Best,
Horia