Python Forum
'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte
#1
Hi,

I'm using python 3.8.5 to call Jira Rest API to download all tickets information and save in a json file AllIssues.json. In order to get all fields, comments from a Jira ticket, I have to make separate Rest API calls for each ticket and get a json file, I save it in a temp file "tmp.json". I'll loop through all tickets in a project and append tmp.json to the AllIssues.json.

The content in tmp.json is displayed correctly in Notepad++ with accent mark but I got error for a specific ticket when appending its json to AllIssues.json, I get the error "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte". Please advice.

#Call Jira Rest API to get a ticket's info and save in tmp.json

with open('tmp.json', encoding='utf-8') as file:
   issue = file.read()
f = open('AllIssue.jsons', "a", encoding="utf-8")
f.write(issue)

#some code
Error:

Error:
-------Successfully created the file C:\Users\OPSWAT\OneDrive - OPSWAT\Jira2SF_Migration\ConversionJsonToCSV\Jira_Data\IssuesFieldsComments_0-10.json IMP-225 IMP-228 IMP-229 Traceback (most recent call last): File "main_v6.py", line 61, in <module> GAI.getTicketFieldsAndComments(TicketKeysToProceed, ticketCommentJson_filePath) File "C:\Users\OPSWAT\OneDrive - OPSWAT\Jira2SF_Migration\Jira_v1\getAllIssues_v6.py", line 58, in getTicketFieldsAndComments issue = file.read() File "C:\Users\OPSWAT\AppData\Local\Programs\Python\Python38\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte
Thanks in advance,

Tien Tran
Reply


Messages In This Thread
'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte - by tienttt - Sep-17-2020, 10:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Search for multiple unknown 3 (2) Byte combinations in a file. lastyle 7 1,324 Aug-14-2023, 02:28 AM
Last Post: deanhystad
Question UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 562: ord ctrldan 23 4,808 Apr-24-2023, 03:40 PM
Last Post: ctrldan
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid cont Melcu54 3 4,932 Mar-26-2023, 12:12 PM
Last Post: Gribouillis
  Decode string ? JohnnyCoffee 1 813 Jan-11-2023, 12:29 AM
Last Post: bowlofred
  extract only text strip byte array Pir8Radio 7 2,928 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
  [SOLVED] [Debian] UnicodeEncodeError: 'ascii' codec Winfried 1 1,024 Nov-16-2022, 11:41 AM
Last Post: Winfried
  sending byte in code? korenron 2 1,119 Oct-30-2022, 01:14 PM
Last Post: korenron
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 34: character Melcu54 7 18,874 Sep-26-2022, 10:09 AM
Last Post: Melcu54
  Byte Error when working with APIs Oshadha 2 1,010 Jul-05-2022, 05:23 AM
Last Post: deanhystad
  UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin Armandito 6 2,723 Apr-29-2022, 12:36 PM
Last Post: Armandito

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020