Endpoint https://api.travis-ci.org/jobs not supported in v3?

Hi, we’re using endpoint https://api.travis-ci.org/jobs (from Client and API isolation) vwhich is great for our project repairnator

This works perfectly for V1, V2:

curl --verbose --header "Accept: application/json; version=1" https://api.travis-ci.org/jobs
curl --verbose --header "Accept: application/json; version=2" https://api.travis-ci.org/jobs

But V3 fails:

curl --verbose --header "Accept: application/json; version=3" https://api.travis-ci.org/jobs
< HTTP/1.1 406 Not Acceptable
< Connection: keep-alive
< Server: nginx
< Date: Mon, 15 Apr 2019 05:10:53 GMT
< Content-Type: application/json;charset=utf-8
< Content-Length: 0
< Strict-Transport-Security: max-age=31536000
< X-Endpoint: Travis::Api::App::Endpoint::Jobs
< X-Pattern: /

What’s the equivalent of endpoint /jobs in the API V3?

Hey there, thanks for reaching out and I’m sorry for the confusion.

I’m checking with our Engineering Team why this doesn’t work with API v3.

Thank you for your patience!

Hi @monperrus, I’m a platform engineer at Travis CI, following up at @dominic 's request.

V3 of our API does support a /jobs endpoint, but for the current_user (i.e. logged-in user). You can see a more detailed description of the endpoint on our V3 developer docs here (you will need to be logged in to Travis CI to see these docs):

https://developer.travis-ci.org/resource/jobs#for_current_user

To make a curl request against V3, you will need to include an Authorization header with a token, like so:

curl --verbose -H "Travis-API-Version: 3" -H "Authorization: token XXXXXX" https://api.travis-ci.org/jobs

You can find your token using our CLI, with travis token, or visiting the Explorer page of our API V3 docs where you’ll see a redacted Authorization token in the example curl request. Scroll over this and the token will become visible.

In your case, for your Spiral-Team/repinator project, if it’s the jobs for that specific repository you need, you can try this endpoint:

repo/Spirals-Team%2Frepairnator/builds

(https://developer.travis-ci.org/resource/builds#Builds)

This will return a list of builds, including all the jobs in each build. You can see an example of this on the Explorer page of our V3 developer docs:

https://developer.travis-ci.org/explore/repo/Spirals-Team%2Frepairnator/builds

I hope that’s helpful. Thanks for the question, and please get back in touch if there’s anything else we can help with.

2 Likes

Hi @carlad!

That’s super helpful, thanks. It works with my token, yet it has a different behavior.

In V1 and V2, /job gives all jobs over all public repos.

In V3 + authentication, this only gives the build of the repos I’m involved in.

How to get all jobs over all public repos in V3?

Thanks!

Hi @monperrus,

Do you mean all jobs for that organization?

Yes, the V3 /jobs endpoint only returns jobs that the current_user has access to.

One way around this could be to create a user that has access to all the organization repos, and use that token to make the request. Not sure if that’s feasible, but currently there’s no way to use V3 in the same way.

but currently there’s no way to use V3 in the same way.

OK. Is there a way to open a feature request so as to get a backward compatible behavior in V3?

Hi @carlad,

How to open a feature request so as to get a backward compatible behavior in V3?

Thanks! --Martin

Hi @monperrus,

I no longer work at Travis CI.

I suggest emailing support@travis-ci.com

Best regards --Carla

1 Like