Error updating an existing datasource using the HTTP API

UPDATE: I’ve identified the cause(s). An update to an existing datasource requires a PUT operation instead of a POST (I missed that in the docs). Also, my datasource had been created with the readOnly flag set to true. It was one (or both) of these issues that was causing the error I was getting.

I’m getting an error when I try to update an existing datasource using the HTTP API.
I’m following the docs at:

Here’s an example showing what I do to recreate the error. Basically I GET the datasource JSON, make a minor edit (eg. change the port number in the url field), then use POST to update the datasource.

$ curl -s -H "$AUTH_HEADER" http://localhost:32774/api/datasources/12 >
$ sed -i -e 's/8282/9999/'
$ curl -s -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "$AUTH_HEADER" -d "$(cat" http://localhost:32774/api/datasources/12
{"message":"Not found"}

The error I see in our docker container logs is:
t=2018-05-03T14:29:20+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=5 uname= method=POST path=/api/datasources/12 status=404 remote_addr= time_ms=27 size=23 referer=

Any idea what would cause the “Not found” message? I’m sending the modified JSON back to the same org (ie. same API Key stored in the $AUTH_HEADER variable above). I did not edit the id, orgId, or any other field besides the port number in the url. And as you can see above I am sending it back to the same datasource (id: 12). Thank you.

Environment/version details:
We are running Grafana v5.0.3 (commit: 91162f3) in a Docker container on Linux hosts.