opsgenie / opsgenie-go-sdk-v2

Opsgenie GO SDK v2
Apache License 2.0
36 stars 65 forks source link

Response could not be parsed, invalid character '<' looking for beginning of value #147

Open madpipeline opened 2 months ago

madpipeline commented 2 months ago

Receiving error:

ERRO[2024-08-28T16:08:21.337077196+03:00] Response could not be parsed, invalid character '<' looking for beginning of value
main_test.go:59: Failed to fetch OpsGenie Alerts: Response could not be parsed, invalid character '<' looking for beginning of value

when trying doing:

alertClient, err := alert.NewClient(&client.Config{
    ApiKey:         opsGenieAPIKey,
    OpsGenieAPIURL: "mycompany.app.opsgenie.com",
})
if err != nil {
    t.Logf("Failed to create OpsGenie Alert Client: %s", err.Error())
    t.FailNow()
}

t.Log("Fetching OpsGenie Alerts...")
listAlertResult, err := alertClient.List(context.Background(), &alert.ListAlertRequest{
    SearchIdentifier: queueName,
})

The documentation does not list which of the fields of ListAlertRequest are mandatory, and there is no example code on how to use the List() function properly.

madpipeline commented 2 months ago

I get a "loading screen" html web page if I try to do the same request using curl:

curl -vvv -XGET -H "Authorization: GenieKey $opsGenieAPIKey" "https://mycompany.app.opsgenie.com/v2/alerts?searchIdentifier=$queueName"

according to the API docs for that endpoint none of the fields are mandatory, so providing just one should be valid.

madpipeline commented 2 months ago

It seems that I was confused by the variable OpsGenieAPIURL in the Golang docs, and I've assumed that since I'm not using "the global" OpsGenie instance and I'm using a customer specific tenant, I should be using the tenant specific domain.

After some testing I found that I should be using always api.opsgenie.com or api.eu.opsgenie.com if I'm using the EU instance.

Both work in my case, so I'm unclear on the difference between the EU and non EU instance.

I'd propose that this should be clarified in the golang SDK documentation on de description of the OpsGenieAPIURL variable.

madpipeline commented 2 months ago

There is a related Atlassian support ticket for this issue: https://support.atlassian.com/requests/OGSP-132626/