Json response of job log gives error in Python

Describe your question in as much detail as possible:
I am using the Jobs API | GitLab to get the log of a job I ran.

I ran the following python code:

response = requests.get(f"https://gitlab.com/api/v4/projects/{projectid}/jobs/{jobid}/trace?private_token={PRIVATE_TOKEN}")

response.json()

I see the following error:


JSONDecodeError Traceback (most recent call last)
File C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py:910, in Response.json(self, **kwargs)
909 try:
→ 910 return complexjson.loads(self.text, **kwargs)
911 except JSONDecodeError as e:
912 # Catch JSON-related errors and raise as requests.JSONDecodeError
913 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError

File C:\ProgramData\Anaconda3\lib\json_init_.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
→ 346 return _default_decoder.decode(s)
347 if cls is None:

File C:\ProgramData\Anaconda3\lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 “”“Return the Python representation of s (a str instance
334 containing a JSON document).
335
336 “””
→ 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()

File C:\ProgramData\Anaconda3\lib\json\decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
354 except StopIteration as err:
→ 355 raise JSONDecodeError(“Expecting value”, s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

JSONDecodeError Traceback (most recent call last)
Input In [29], in <cell line: 2>()
1 response = requests.get(f"https://gitlab.com/api/v4/projects/36516223/jobs/2581256791/trace?private_token={PRIVATE_TOKEN}")
----> 2 response.json()

File C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py:917, in Response.json(self, **kwargs)
915 raise RequestsJSONDecodeError(e.message)
916 else:
→ 917 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

JSONDecodeError: [Errno Expecting value] Running with gitlab-runner 15.1.0~beta.20.g62206bb2 (62206bb2)
on green-4.shared.runners-manager.gitlab.com/default ntHFEtyX
Resolving secrets
Preparing the “docker+machine” executor
Using Docker executor with image registry.gitlab.com/pg3group/pg3-sw/ubuntu
Authenticating with credentials from job payload (GitLab Registry)

I am using docker container of Ubuntu OS create environment in which the CI runs.

I am attaching raw output and screen shot of error.