Grafana Admin APIs - Update Datasource via Rest HTTP

Hello,

Im using Grafana version v7.4.3
Im trying to update a certificate and key to an existing datasource via Admin API call but getting an error:
“classification”:“DeserializationError”,“message”:“invalid character ‘\n’ in string literal”
I assume this is related to both parameters secureJsonFields.tlsClientCert and secureJsonFields.tlsClientKey.

I review the API Admin - datasource documentation

I didn’t found any reference to secureJsonFields.tlsClientCert and secureJsonFields.tlsClientKey, so I tried to set their values with base64 and without it. both attempts fails.

the call I where using:
curl --location --request PUT ‘<GRAFANA_SERVER>/api/datasources/’
–header ‘Content-Type: application/json’
–header ‘Authorization: Bearer GRAFANA_API_KEY’
–data-raw ‘{“secureJsonFields”:{“tlsClientCert”:“CERTIFICATE_VALUE”,“tlsClientKey”:“KEY_VALUE”}
}’

Is there any documentation regarding how to update certificate and key to an existing datasource?

Thank you in advance
Shalom

hi @shalomyaish

I just stepped on a similar issue here

Try wrapping your data under secureJsonData instead of secureJsonFields

hope it works in your case too