Having issues with API requests when authenticating using a domain user

Article ID:360053178791
1 minute readKnowledge base

Issue

I’m trying to make an API call to my Jenkins instance using my domain user but it’s failing with:

curl: (7) Failed to connect to yourdomain.com port X: Connection timed out

It mainly affects users with a "@" character.

Resolution

This is caused by the "@" character, that makes the call interpret your user’s domain as the URL to reach.

It can be fixed by replacing your call, defining the user and token as an argument.

  • Example of a command that will fail

curl https://youruser@yourdomain.com:yourtoken@jenkins.yourdomain.com/api/json
  • Example of a successful command

curl -u youruser@yourdomain.com:yourtoken https://jenkins.yourdomain.com/api/json