launchdarkly

JSON Body for "AddUserTargets" Patch Request


I'm attempting to patch a feature flag via the API, adding an individual target to the flag following the documentation for patching feature flags.

Targeting an API route of https://app.launchdarkly.com/api/v2/flags/foo/bar

Where bar is a boolean flag, I'm using the body:

{
    "instructions":[{"kind": "addUserTargets", "values":["foo@bar.com"],"variationId": "True"}],
    "environmentKey": "development"
}

I am receiving a return of

enter image description here

What am I doing wrong in my request body? I haven't been able to find the variationId through the Darkly UI

Edit: Proof of Proper Headers - enter image description here


Solution

  • Looking at it further, it appears that you are in fact missing the variation ID on the flag you are attempting to patch, which is a required field.

    You would need to make a request to gather that data as described here and then modify your request accordingly.