Unhelpful error msg if API command typo

I just wasted way too much time trying to understand why an API command would not work.

Instead of a REST response error message I was getting a blank HTML page with a lot of javascript, and no other indication of a problem.

I was trying . . .

curl -X POST --header "Content-Type: application/json" -d '{"type":"deploy-key"}' https://circleci.com/api/v1/project/:username/:project/checkout_key?circle-token=:token  -H "Accept: application/json"

. . . when I should have written . . .

curl -X POST --header "Content-Type: application/json" -d '{"type":"deploy-key"}' https://circleci.com/api/v1/project/:username/:project/checkout-key?circle-token=:token  -H "Accept: application/json"

See the difference?

Ouch – I had to use a diff to see the difference. Thank you for letting us know. :slight_smile:

1 Like

Spend some time looking at the diff—the difference seems to be in using the dash ( - ) in the correct variant and underscore ( _ ) in the one that didn’t work.

Alexey, I’m sorry … you misunderstood the point of my post.

I found the _ vs - error myself. The point was that the REST API error response was absolutely useless in helping me determine quickly what I had done wrong. Were the response to have been . . .

Unknown command 'checkout_key'.  Cannot process.

. . . I would have solved it instantly.

3 Likes

Got it, Martin, thanks for clarifying. We’ll see what we can do about this.

2 Likes

@alexey @martinhbramwell this might sound dumb, but you didn’t actually leave the URL with e.g. :username and :project right? You have to swap those values with the actual username and project you want to point to…

I’m asking because I’m having an issue like the one you described:

Instead of a REST response error message I was getting a blank HTML page with a lot of javascript, and no other indication of a problem.

Here’s my command:

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" "https://circleci.com/api/v1.1/project/gh/:username/:project?circle-token=${CIRCLE_TOKEN}"