Update Secrets API not working?

I’ve been testing out the secrets endpoints and noticed that update is not working. I’ve followed the API documentation and tested using the doppler provided postman collection but it continues to fail. Is anyone else experiencing something similar? Any help is appreciated!

Below is a sample of how my request is structured.

curl --request POST \
     --url https://api.doppler.com/v3/configs/config/secrets \
     --header 'accept: application/json' \
     --header 'authorization: Bearer my_service_key' \
     --header 'content-type: application/json' \
     --data '
{
  "project": "my_project_name",
  "config": "my_config_name",
  "secrets": {
    "my_secret_name: "my_secret_value"
  }
}
'

Hi @went,

Could you provide the full output you’re getting back? I just tested this endpoint myself and it worked as expected. Are you using a service token you created specifically for the config? Or are you using your local CLI token for testing? To rule out a token issue, try changing your authorization header line to this:

--header 'authorization: Bearer $(doppler configure get token --plain)' \

that will have it use your local CLI token, which should have access to all projects and configs in your workplace (assuming you’re an Owner). If that works, then the issue is likely with the service token you were using. If it still doesn’t work, post the output and I’ll see what I can do to help!

Regards,
-Joel

@watsonian,
Thank you for the response. Currently I’m not using the CLI, I’m testing everything in Postman using a Service Token.

When I call the endpoint from Postman I’m getting:

  • Status: 400 Bad Request
  • Body:
{
    "messages": [
        "Either secrets or change_requests must be specified"
    ],
    "success": false
}

Hi @went,

Not sure if this was a copy/paste mistake, but your JSON is malformed. You’re missing a closing quote next to the secret name. That said, I’d expect an invalid JSON error in the response if that were the problem. I just ran this and it worked fine:

curl --request POST \
     --url https://api.doppler.com/v3/configs/config/secrets \
     --header "accept: application/json" \
     --header "authorization: Bearer $(doppler configure get token --plain)" \
     --header "content-type: application/json" \
     --data '
{
  "project": "my_project_name",
  "config": "my_config_name",
  "secrets": {
    "my_secret_name": "my_secret_value"
  }
}
'

If you run the curl command in the CLI manually outside of Postman, what happens? My suspicion is this may be some issue with how Postman is setup.

Regards,
-Joel

@watsonian ,
Yes…that was a copy/paste error. The Body I have specified in Postman has properly formatted JSON.

Thank you for the advice. I tested outside of postman and its working. So postman must have some sort of configuration that is producing this oddity. I’ll continue to tinker and I’ll compare my collection to Doppler’s public postman workspace.

Thank you again!

I found the Postman setting that is required for this to work.

You must ensure the Content-Length generated header is included in the request.
image