'failed to parse JSON input

I'm trying to POST a configuration file to vault and i'm getting {"errors":["failed to parse JSON input: invalid character 'a' in numeric literal"]} error. The file is not in JSON format. Any thoughts?

curl -H "X-Vault-Token: $VAULT_TOKEN" -H "Content-Type: application/json" -XPOST --upload-file "$HOME/config"  url-to-where-it-should-post/sample_deployment/config


Solution 1:[1]

I used the following configuration to push a yaml file to Hashicorp Vault.

For pushing the yaml file directly:

curl -k -H 'X-Vault-Token: <vault_token>' -X POST --data @test.yaml https:///v1/secret/foo/bar"

If you would like to encode the file before pushing to Vault:

base64 test.yaml | curl -k -H "X-Vault-Token: <vault_token>" -X POST --data @- https://<vault_host>/v1/secret/foo/bar

In the above command, the output of base64 will be passed on to the '@-'. The '-' stands for take your value from stdin and this case it is the bash output.

For testing if the secret got pushed:

curl -s -k -H 'X-Vault-Token: <vault_token>' https://<vault_host>/v1/secret/foo/bar

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharu