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
#11
(Sep-18-2020, 03:24 PM)tienttt Wrote: This is my previous code. I realized the json I got from Jira Rest API is correct but json.dumps() makes it incorrect.
It's the plain text of the HTTP message body you get back now,which is not json.
Also strange that you do call in a subprocess.
The API Doc usually have expiation of login with OAuth and getting the json response back,all this can of course be done in Requests alone.
Reply
#12
Hi Snippsat,

Jira provide a sample code in Java to call their REST API and I leverage their OAuthTutorialClient-1.0.jar. That's why I use subprocess to run a command in cmd. The result of command line is a string in json-format. I use json.loads() to load that string to the variable "issue" before pass it to json.dumps() and append it to the AllIssue.json file.

Regards,
Tien
Reply
#13
I rewrite the function and use Requests lib to call Jira Rest API directly, then use json.dump(). The issue is resolved. Thanks all.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Search for multiple unknown 3 (2) Byte combinations in a file. lastyle 7 1,257 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,608 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,702 Mar-26-2023, 12:12 PM
Last Post: Gribouillis
  Decode string ? JohnnyCoffee 1 788 Jan-11-2023, 12:29 AM
Last Post: bowlofred
  extract only text strip byte array Pir8Radio 7 2,790 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
  [SOLVED] [Debian] UnicodeEncodeError: 'ascii' codec Winfried 1 988 Nov-16-2022, 11:41 AM
Last Post: Winfried
  sending byte in code? korenron 2 1,087 Oct-30-2022, 01:14 PM
Last Post: korenron
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 34: character Melcu54 7 18,309 Sep-26-2022, 10:09 AM
Last Post: Melcu54
  Byte Error when working with APIs Oshadha 2 980 Jul-05-2022, 05:23 AM
Last Post: deanhystad
  UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin Armandito 6 2,644 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