Hello! My company uses a self-hosted GrowthBook, c...
# ask-questions
a
Hello! My company uses a self-hosted GrowthBook, currently version 2023-11-27. I am trying to automate the process of launching A/B tests. I successfully managed to create a feature with API request, but I’m unable to create an experiment and link it to the feature—it returns a 400 error (example of error: b’{“message”:“Invalid data source: “}’;). I don’t have datasources and can run experiments without it using admin panel. The documentation seems to be written for the latest version. Is there any way to access documentation specifically for version 2023-11-27 to see all possible parameters? Here’s the python code I have right now. I would greatly appreciate your help and thank you in advance!
Copy code
headers = {
    'Authorization': f'Bearer {api_key}',
     'Content-Type': 'application/json',
     'Accept': 'application/json'
}
payload = {
        "datasourceId": "",
        "assignmentQueryId": "",
        "trackingKey": experiment_id_key,
        "name": experiment_id_key,
        "project": project_id,
        "hypothesis": "",
        "description": "",
        "tags": [],
        "metrics": [],
        "guardrailMetrics": [],
        "owner": '<mailto:qwerty123@gmail.com|qwerty123@gmail.com>',
        "archived": False,
        "status": "running",
        "autoRefresh": True,
        "hashAttribute": "id",
        # "fallbackAttribute": "string",
        "hashVersion": 2,
        "releasedVariationId": "",
        "excludeFromPayload": True,
        "variations": [
            {
                "id": "var_m1z8651l",
                "name": "Control",
                "key": "0",
                "screenshots": [],
                "description": ''
            },
            {
                "id": "var_m1z8651m",
                "name": "Variation 1",
                "key": "1",
                "screenshots": [],
                "description": ''
            }
        ],
        "phases": [
            {
                "name": "string",
                "dateStarted": "2019-08-24T14:15:22Z",
                "seed": experiment_id_key,
                "coverage": 1,
                "trafficSplit": [
                    {"variationId": "0", "weight": 0.5},
                    {"variationId": "1", "weight": 0.5}
                ],
                "namespace": {
                    "namespaceId": "",
                    "range": [
                        0,
                        0.5
                    ],
                    "enabled": False
                },
                "targetingCondition": "",
                "reason": "",
                "condition": "{\"flowId\": \"1111\", \"language\": \"en\"}",
                "savedGroupTargeting": [],
                "variationWeights": [
                    0.5,
                    0.5
                ],
            }
        ]
    }

response = <http://requests.post|requests.post>(f"{api_url}", headers=headers, data=json.dumps(payload))
f
Hi Borozniuk - What admin panel?
We don't keep old docs around (and we recommending keeping your platform up todate)
but you're welcome to look through the git history and run the docs yourself
a
web version i mean (when i create it manually)
the main question is why datasourceId and assignmentQueryId are required params for API post request, but not needed when you create experiments manually with a help of features? As far as I understand it is needed only to check stats between variations
👍 1
1
@fresh-football-47124 I hope you’re doing well! Have you had a chance to review my question above? I’d greatly appreciate your input whenever it’s convenient for you. Thank you in advance!