https://www.growthbook.io/ logo
#announcements
Title
# announcements
a

ambitious-apartment-58735

09/14/2023, 5:29 PM
Hi, I’m trying to update a single experiment from the API, but no matter how I format the request data I get an error like
Unrecognized key(s) in object: '{ name: \"test_experiment\"}'"}%
. I have no problem getting experiment data via API (we’re self-hosted), but following the documentation to update an experiment (https://docs.growthbook.io/api#tag/experiments/operation/updateExperiment) doesn’t work, and neither have a few variations on that (eg sending the data as a json file). This may be more of an API question (I don’t work with them often) than a GB one, but any advice you have would be appreciated. (Googling the unrecognized key error hasn’t helped.) Thanks!
b

brief-honey-45610

09/14/2023, 6:18 PM
Hi Jane, thanks for reaching out! I’ll run this by our API team and let you know what I find out
Jane, would you mind sharing the cURL request or code you're using to make the API call that is erroring out?
a

ambitious-apartment-58735

09/14/2023, 6:55 PM
Thanks! Here’s an example (removing all our details) of the style of what I’ve tried that’s not working for me to update an experiment
Copy code
curl -X POST [api_home]/api/v1/experiments/experiment_id \
 -d '{"id":"experiment_id", "name":"Sample Test",[…]}' \
 -u [my_secret_key]:
I similarly tried creating a test experiment
Copy code
curl -X POST [api_home]/api/v1/experiments \
 -d '{"id":"experiment_id", "name":Sample Test",[…]}' \
 -u [my_secret_key]:
I tried different variations on the key quoting but none of that helped
b

brief-honey-45610

09/14/2023, 8:07 PM
Hi Jane, these were very helpful, thank you
We are still looking into this
Good news! Looks like all that was missing was the Content Type header. If you add it to your cURL request it should work perfectly:
Copy code
curl -X POST [api_home]/api/v1/experiments/experiment_id \
  -d '{ "name": "updated_name"}' \
  -H 'Content-Type: application/json' \
  -u secret_1234:
@ambitious-apartment-58735 ^
a

ambitious-apartment-58735

09/14/2023, 9:06 PM
i had tried with that before but let me try again
🤔 1
i tried creating an experiment following that and added the require arguments but still get
Unrecognized key(s) in object: 'settings'"
is it possible share a working example for creating a new experiment? i can test if that works for me
b

brief-honey-45610

09/15/2023, 4:06 AM
Hi Jane, I'm perplexed! I will connect with our API engineer again tomorrow and hopefully we can give you a new approach to try.
👍 1
10 Views