Datasource Test using API?

I created a datasource(InfluxDB) using API with this information

{
        "name": datasource_name,
        "database": datasource_name,
        "type": "influxdb",
        "access": "proxy",
        "url": "http://qegrafana.net:8086",
        "basicAuth": True,
        "basicAuthUser": '{user}',
        "secureJsonData": {
            "basicAuthPassword": '{password}'
        }
    }

also I created a dashboard using the API and with some panels using this datasource but when I edit one of these panels looks like the Datasource was not created correctly. What I need to do is go to datasource settings and click on the Save and Test button of a specific datasource and with this the dashboard panels start to work.

Is there any way to do this(Save and Test) by API instead of doing it manually?

what version of grafana are you running? please provide as much detail as possible

Same problem here. Grafana v9.1.2. Adding InfluxDB data source using Grafana API Golang client. The data source is created successfully but cannot be selected in a dashboard panel until I go to data sources settings > my InfluxDB data source, and click Save & test manually.