curl with Umlaut causes “JSON parse error: Invalid UTF-8 middle byte 0x22” [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite













This question already has an answer here:



  • Curl JSON encoded in UTF-8

    2 answers



I'm running below curl command from the command line (Git Bash on Windows) or as part of a Bash Script.



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d ""testField":"ä"" https://someurl...


Please note that the body of the curl command has an Umlaut ä.



The server which is a Spring Boot REST API running in an AWS Elastic Beanstalk Container returns the following error:



JSON parse error: Invalid UTF-8 middle byte 0x22; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x22n at [Source: (PushbackInputStream); line: 1, column: 17]


The same curl command imported into Postman works just fine, so I believe it's rather a curl issue than a server problem.



Any advise on how to get this curl command work is greatly appreciated!







share|improve this question













marked as duplicate by jayhendren, G-Man, Jesse_b, Vlastimil, Kiwy May 3 at 9:01


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Why not use a Unicode escape?
    – Ignacio Vazquez-Abrams
    May 2 at 20:02










  • The inputs come from users either as a copy paste or a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10






  • 1




    The issue isn't really the accented character; it's that the data encoding does not match the parse encoding. How would your system react if the input were, say, ISO 2022-JP encoded instead of (I assume) Windows code page 1252? Just ignoring text within quotes doesn't cut it, because 0x22 is not always " in ISO 2022-JP. Can you enforce a specific input encoding? If not, can you reliably determine the encoding given?
    – Fox
    May 2 at 20:55














up vote
0
down vote

favorite













This question already has an answer here:



  • Curl JSON encoded in UTF-8

    2 answers



I'm running below curl command from the command line (Git Bash on Windows) or as part of a Bash Script.



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d ""testField":"ä"" https://someurl...


Please note that the body of the curl command has an Umlaut ä.



The server which is a Spring Boot REST API running in an AWS Elastic Beanstalk Container returns the following error:



JSON parse error: Invalid UTF-8 middle byte 0x22; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x22n at [Source: (PushbackInputStream); line: 1, column: 17]


The same curl command imported into Postman works just fine, so I believe it's rather a curl issue than a server problem.



Any advise on how to get this curl command work is greatly appreciated!







share|improve this question













marked as duplicate by jayhendren, G-Man, Jesse_b, Vlastimil, Kiwy May 3 at 9:01


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Why not use a Unicode escape?
    – Ignacio Vazquez-Abrams
    May 2 at 20:02










  • The inputs come from users either as a copy paste or a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10






  • 1




    The issue isn't really the accented character; it's that the data encoding does not match the parse encoding. How would your system react if the input were, say, ISO 2022-JP encoded instead of (I assume) Windows code page 1252? Just ignoring text within quotes doesn't cut it, because 0x22 is not always " in ISO 2022-JP. Can you enforce a specific input encoding? If not, can you reliably determine the encoding given?
    – Fox
    May 2 at 20:55












up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:



  • Curl JSON encoded in UTF-8

    2 answers



I'm running below curl command from the command line (Git Bash on Windows) or as part of a Bash Script.



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d ""testField":"ä"" https://someurl...


Please note that the body of the curl command has an Umlaut ä.



The server which is a Spring Boot REST API running in an AWS Elastic Beanstalk Container returns the following error:



JSON parse error: Invalid UTF-8 middle byte 0x22; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x22n at [Source: (PushbackInputStream); line: 1, column: 17]


The same curl command imported into Postman works just fine, so I believe it's rather a curl issue than a server problem.



Any advise on how to get this curl command work is greatly appreciated!







share|improve this question














This question already has an answer here:



  • Curl JSON encoded in UTF-8

    2 answers



I'm running below curl command from the command line (Git Bash on Windows) or as part of a Bash Script.



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d ""testField":"ä"" https://someurl...


Please note that the body of the curl command has an Umlaut ä.



The server which is a Spring Boot REST API running in an AWS Elastic Beanstalk Container returns the following error:



JSON parse error: Invalid UTF-8 middle byte 0x22; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x22n at [Source: (PushbackInputStream); line: 1, column: 17]


The same curl command imported into Postman works just fine, so I believe it's rather a curl issue than a server problem.



Any advise on how to get this curl command work is greatly appreciated!





This question already has an answer here:



  • Curl JSON encoded in UTF-8

    2 answers









share|improve this question












share|improve this question




share|improve this question








edited May 2 at 19:56









Jeff Schaller

31.1k846105




31.1k846105









asked May 2 at 19:55









Bernie Lenz

1104




1104




marked as duplicate by jayhendren, G-Man, Jesse_b, Vlastimil, Kiwy May 3 at 9:01


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by jayhendren, G-Man, Jesse_b, Vlastimil, Kiwy May 3 at 9:01


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • Why not use a Unicode escape?
    – Ignacio Vazquez-Abrams
    May 2 at 20:02










  • The inputs come from users either as a copy paste or a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10






  • 1




    The issue isn't really the accented character; it's that the data encoding does not match the parse encoding. How would your system react if the input were, say, ISO 2022-JP encoded instead of (I assume) Windows code page 1252? Just ignoring text within quotes doesn't cut it, because 0x22 is not always " in ISO 2022-JP. Can you enforce a specific input encoding? If not, can you reliably determine the encoding given?
    – Fox
    May 2 at 20:55
















  • Why not use a Unicode escape?
    – Ignacio Vazquez-Abrams
    May 2 at 20:02










  • The inputs come from users either as a copy paste or a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10






  • 1




    The issue isn't really the accented character; it's that the data encoding does not match the parse encoding. How would your system react if the input were, say, ISO 2022-JP encoded instead of (I assume) Windows code page 1252? Just ignoring text within quotes doesn't cut it, because 0x22 is not always " in ISO 2022-JP. Can you enforce a specific input encoding? If not, can you reliably determine the encoding given?
    – Fox
    May 2 at 20:55















Why not use a Unicode escape?
– Ignacio Vazquez-Abrams
May 2 at 20:02




Why not use a Unicode escape?
– Ignacio Vazquez-Abrams
May 2 at 20:02












The inputs come from users either as a copy paste or a text file, so I'd like to avoid having to manually convert any extended ascii characters.
– Bernie Lenz
May 2 at 20:10




The inputs come from users either as a copy paste or a text file, so I'd like to avoid having to manually convert any extended ascii characters.
– Bernie Lenz
May 2 at 20:10




1




1




The issue isn't really the accented character; it's that the data encoding does not match the parse encoding. How would your system react if the input were, say, ISO 2022-JP encoded instead of (I assume) Windows code page 1252? Just ignoring text within quotes doesn't cut it, because 0x22 is not always " in ISO 2022-JP. Can you enforce a specific input encoding? If not, can you reliably determine the encoding given?
– Fox
May 2 at 20:55




The issue isn't really the accented character; it's that the data encoding does not match the parse encoding. How would your system react if the input were, say, ISO 2022-JP encoded instead of (I assume) Windows code page 1252? Just ignoring text within quotes doesn't cut it, because 0x22 is not always " in ISO 2022-JP. Can you enforce a specific input encoding? If not, can you reliably determine the encoding given?
– Fox
May 2 at 20:55










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Try replacing the character ä with its UTF8 encoding u00e4:



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '"testField":"u00e4"' https://someurl..





share|improve this answer





















  • The inputs come from users either as a copy paste or via a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10










  • Then you'll need to use a Unicode encoding library of some kind. There are ones available in most popular languages (Python, PHP), so just choose your favorite...
    – jayhendren
    May 2 at 20:18











  • If you want to stick to bash, you can probably use jq. For instance: echo '"testField":"u00e4"' | jq . -a yields "testField": "u00e4" .
    – jayhendren
    May 2 at 20:24

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













Try replacing the character ä with its UTF8 encoding u00e4:



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '"testField":"u00e4"' https://someurl..





share|improve this answer





















  • The inputs come from users either as a copy paste or via a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10










  • Then you'll need to use a Unicode encoding library of some kind. There are ones available in most popular languages (Python, PHP), so just choose your favorite...
    – jayhendren
    May 2 at 20:18











  • If you want to stick to bash, you can probably use jq. For instance: echo '"testField":"u00e4"' | jq . -a yields "testField": "u00e4" .
    – jayhendren
    May 2 at 20:24














up vote
1
down vote













Try replacing the character ä with its UTF8 encoding u00e4:



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '"testField":"u00e4"' https://someurl..





share|improve this answer





















  • The inputs come from users either as a copy paste or via a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10










  • Then you'll need to use a Unicode encoding library of some kind. There are ones available in most popular languages (Python, PHP), so just choose your favorite...
    – jayhendren
    May 2 at 20:18











  • If you want to stick to bash, you can probably use jq. For instance: echo '"testField":"u00e4"' | jq . -a yields "testField": "u00e4" .
    – jayhendren
    May 2 at 20:24












up vote
1
down vote










up vote
1
down vote









Try replacing the character ä with its UTF8 encoding u00e4:



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '"testField":"u00e4"' https://someurl..





share|improve this answer













Try replacing the character ä with its UTF8 encoding u00e4:



curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '"testField":"u00e4"' https://someurl..






share|improve this answer













share|improve this answer



share|improve this answer











answered May 2 at 20:07









jayhendren

5,07721340




5,07721340











  • The inputs come from users either as a copy paste or via a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10










  • Then you'll need to use a Unicode encoding library of some kind. There are ones available in most popular languages (Python, PHP), so just choose your favorite...
    – jayhendren
    May 2 at 20:18











  • If you want to stick to bash, you can probably use jq. For instance: echo '"testField":"u00e4"' | jq . -a yields "testField": "u00e4" .
    – jayhendren
    May 2 at 20:24
















  • The inputs come from users either as a copy paste or via a text file, so I'd like to avoid having to manually convert any extended ascii characters.
    – Bernie Lenz
    May 2 at 20:10










  • Then you'll need to use a Unicode encoding library of some kind. There are ones available in most popular languages (Python, PHP), so just choose your favorite...
    – jayhendren
    May 2 at 20:18











  • If you want to stick to bash, you can probably use jq. For instance: echo '"testField":"u00e4"' | jq . -a yields "testField": "u00e4" .
    – jayhendren
    May 2 at 20:24















The inputs come from users either as a copy paste or via a text file, so I'd like to avoid having to manually convert any extended ascii characters.
– Bernie Lenz
May 2 at 20:10




The inputs come from users either as a copy paste or via a text file, so I'd like to avoid having to manually convert any extended ascii characters.
– Bernie Lenz
May 2 at 20:10












Then you'll need to use a Unicode encoding library of some kind. There are ones available in most popular languages (Python, PHP), so just choose your favorite...
– jayhendren
May 2 at 20:18





Then you'll need to use a Unicode encoding library of some kind. There are ones available in most popular languages (Python, PHP), so just choose your favorite...
– jayhendren
May 2 at 20:18













If you want to stick to bash, you can probably use jq. For instance: echo '"testField":"u00e4"' | jq . -a yields "testField": "u00e4" .
– jayhendren
May 2 at 20:24




If you want to stick to bash, you can probably use jq. For instance: echo '"testField":"u00e4"' | jq . -a yields "testField": "u00e4" .
– jayhendren
May 2 at 20:24


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?