Problem inserting values with backslashes in hashicorp vault

Hi everyone.

I wanted to ask you something.
I have tried to insert secrets in vault with special characters like backslash "\".
I have currently a KEY asociated to a domain user and his value contains backslashes and I have an error when I try insert it.
The test Iā€™m doing is trough vault api, like that:

curl \
  -H 'X-Vault-Token: MYTOKEN' \
  -H 'Content-Type: application/json' \
  -X POST \
  -d @/tmp/file.json \
  https://myvaulturl:8200/v1/secret/data/mypath

And I have this error:

{"errors":["error parsing JSON"]}

My file.json is this:

{
  "data": {
    "DOMAINUSER": "\MYDOMAIN\country\name"
  }
}

I have tested with differents files, trying escape backslashes, putting double and triple backslashes but the result is the same.

Can you help me and tell me how must I set the file correctly?.
Thanks you so much.

UPDATE
I had an error in my curl command, the ā€œ@ā€ character was missing before the file name. I already have fixed in original command.
And finally with two backslashes it works.

Thank you!

1 Like