Integration with CIrcleCI using REST API

api

#1

Hi Guys,

I have the following question: I am trying to download the latest artifacts using API method
curl -X GET https://circleci.com/api/v1.1/project/github/< username >/< project >/latest/artifacts?circle-token=< token >&branch=master&filter=completed

But the response is empty [ ], and I see that it was split into two different responses.

I’ve started the command but response was getting when the command finished.
autotest-MacBook-Pro: autotest$ curl -X GET https://circleci.com/api/v1.1/project/github/< username >/< project >/latest/artifacts?circle-token=< token >&branch=master&filter=completed
[1] 23873
[2] 23874
[2]+ Done branch=master
autotest-MacBook-Pro: autotest$ [ { correct response here } ]

I used the CircleCI API earlier and hadn’t faced with this issue.
Probably something was changed in API and I should add something here to get the result in the first response?

Thanks


#2

Hmm. Per https://circleci.com/docs/api/#artifacts-of-the-latest-build that’s correct. Let me run some tests to see if I can reproduce.

Are you using a project token, or a user token?

Edit: I can’t reproduce this: https://circleci.com/api/v1.1/project/github/drazisil/mco-server/latest/artifacts?branch=master&filter=completed (token not needed since it’s a public project)

Confirmed that accessing a private project with the wrong token return Project not found, not empty.


#3

I use the user token for it.


#4

Silly question then, are you sure the master branch’s latest job has artifacts? If you are using a workflow it may be that one of the jobs in the workflow has the artifacts, but not the latest one.


#5

I see the not empty response in the second part of the output but when I run it in terminal I see that the curl command finished with output
[1] 23873
[2] 23874
[2]+ Done branch=master

and over time I get the valid response in the terminal
It seems as the request was performed in another thread or it was redirected

I see the same issue with Postman and HttpClient java. It returns the code=200 and response=[ ]


#6

Very strange. Sent you a DM.


#7

Regenerating the API token resolved this.


closed #8

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.