Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugging: add printing of request & response for schedule override
This is to help with debugging issue #339. This branch is based off of #325, so that I could make use of the new response debugging functionality I added. I ran the following commands from within the `command` directory to get the below result: ```shell go build -o pd . ./pd schedule override create -authtoken "$(cat ../api.key)" PF4QFIN debug_override.json ``` The `api.key` file is just an API key from the PD console. `PF4QFIN` is a PagerDuty service in my development account. Here is the output: ``` time="2021-07-04T01:00:24-07:00" level=info msg="service id is:PF4QFIN" time="2021-07-04T01:00:24-07:00" level=info msg="Input file is:debug_override.json" req: req.Method: POST req.URL: https://api.pagerduty.com/schedules/PF4QFIN/overrides req.Header: http.Header{"Accept":[]string{"application/vnd.pagerduty+json;version=2"}, "Authorization":[]string{"Token token=u+XP5yPH7pzsQ3aJA5EQ"}, "Content-Type":[]string{"application/json"}, "User-Agent":[]string{"go-pagerduty/1.5.0"}} req.Body: {"override":{"start":"2021-06-29T12:00:00Z","end":"2021-06-29T18:00:00Z","user":{"id":"P6QKA9O"}}} err: HTTP response with status code 400, JSON error object decode failed: json: cannot unmarshal string into Go struct field APIError.error of type []string resp: resp.Status: 400 Bad Request resp.Header: http.Header{"Access-Control-Allow-Headers":[]string{"Authorization, Content-Type, AuthorizationOauth, X-EARLY-ACCESS"}, "Access-Control-Allow-Methods":[]string{"GET, POST, PUT, DELETE, OPTIONS"}, "Access-Control-Allow-Origin":[]string{"*"}, "Access-Control-Expose-Headers":[]string{""}, "Access-Control-Max-Age":[]string{"1728000"}, "Cache-Control":[]string{"no-cache"}, "Connection":[]string{"keep-alive"}, "Content-Length":[]string{"95"}, "Content-Type":[]string{"application/json"}, "Date":[]string{"Sun, 04 Jul 2021 08:00:24 GMT"}, "Server":[]string{"nginx"}, "X-Request-Id":[]string{"f6cda459-587c-49a6-ab98-17fc5bd60642"}} resp.Body: {"error":{"message":"Invalid Override","code":2001,"errors":"Invalid input for this override"}} ``` Note that `error.errors` is not an array, it's a single string. This seems to violate the API spec.
- Loading branch information