Updating Annotation via API

Hi,
I am trying to update the timeEnd via the Annotation API and I always get an error. See example below.
Create Annotation:
curl -s -X POST -H 'Authorization: Bearer <whatever>' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{ "time":1527816482028, "timeEnd":1527817082030, "isRegion":true, "tags":[ "Test-A", "jenkins", "smoketest"], "text":"Jenkins (Preliminary): Smoketest_Test-A - 59" }' http://XYZ:3000/api/annotations

Update Annotation:
curl -s -X PUT -H 'Authorization: Bearer ’ -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -d ‘{ “time”:1527816482028, “timeEnd”:1527816505249, “isRegion”:true, “tags”:[ “Test-A”, “jenkins”, “smoketest”], “text”:“Jenkins: Smoketest_Test-A - 59” }’ http://XYZ:3000/api/annotations/53
{“message”:“Failed to update annotation for region end time”}

If I look at the code there definitely is something weird here but I don’t yet understand Grafana internals so have no clue what they are talking about. (annotations.go)

if cmd.IsRegion {
	itemRight := item
	itemRight.RegionId = item.Id
	itemRight.Epoch = cmd.TimeEnd

	// We don't know id of region right event, so set it to 0 and find then using query like
	// ... WHERE region_id = <item.RegionId> AND id != <item.RegionId> ...
	itemRight.Id = 0

	if err := repo.Update(&itemRight); err != nil {
		return Error(500, "Failed to update annotation for region end time", err)
	}

}

Thanks for any help here! :slight_smile:
Oliver

Solved it:

The setting of the Annotation comes back with two IDs ({“endId”:119,“id”:118,“message”:“Annotation added”}). You need to use the id when updating. Trying it on the endId will fail as above.