JSON with special characters

Post Reply
mart3223
Member
Posts: 28
Joined: Mon May 07, 2018 3:00 pm

JSON with special characters

Post by mart3223 »

Hi All,

In my last Topic I was building a POST to a API. That is working fine right now with normal characters, the specials like "é" and "ë" are a problem right now. If I post this JSON with Postman everything is working fine:

Code: Select all

{"parcel":{"address":"Kattegat 18","city":"Groningen","company_name":"Tëst ","country":"NL","email":"support@none.nl","name":"Tést","order_number":"1234","parcel_items":[{"description":"BOEKEN","quantity":1,"sku":"97890828","value":"0","weight":"1"}],"postal_code":"9723JP","sender_address":57138,"shipment":{"id":492},"telephone":""}}
If I use the same JSON in Enfocus Switch and make a POST I get a empty response, no error nothing. The header I use "Content-Type:application/json" does someone have a idea what i'm doeing wrong?

Kind regards, Martijn
Working with: Enfocus Switch, Pitstop Server, Quite Imposing, Kodak Nexpress (max 640mm sheets and 500grs) with most options (HD, Clear, Gold, White, Light-Black and Matt fuser), Polar Mohr D80 (compucut), Multigraf, Heidelberg, GMP, Duplo, Hohner.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: JSON with special characters

Post by gabrielp »

Curious -- does your web server/API get the request? Is it returning an empty response? Or is the request not even getting there?
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
mart3223
Member
Posts: 28
Joined: Mon May 07, 2018 3:00 pm

Re: JSON with special characters

Post by mart3223 »

gabrielp wrote: Wed Feb 27, 2019 3:48 pm Curious -- does your web server/API get the request? Is it returning an empty response? Or is the request not even getting there?
Yes, it is returning a empty response. No error. If I use a JSON without special characters everything is working fine.
Working with: Enfocus Switch, Pitstop Server, Quite Imposing, Kodak Nexpress (max 640mm sheets and 500grs) with most options (HD, Clear, Gold, White, Light-Black and Matt fuser), Polar Mohr D80 (compucut), Multigraf, Heidelberg, GMP, Duplo, Hohner.
sander
Advanced member
Posts: 274
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: JSON with special characters

Post by sander »

mart3223 wrote: Tue Feb 26, 2019 10:52 am If I use the same JSON in Enfocus Switch
Could be a encoding issue. How do you create your json on the Switch server, and how do you post?

e.g. If you create your json via FileWrite try using UTF-8: File.write(json, jsonBody,'UTF-8')
mart3223
Member
Posts: 28
Joined: Mon May 07, 2018 3:00 pm

Re: JSON with special characters

Post by mart3223 »

We use the app "Make JSON" and the POST function in Enfocus. I have add some screenshots.

The setting of the POST (HTTP reuest app)
Schermafbeelding 2019-02-27 om 17.18.41.png
Schermafbeelding 2019-02-27 om 17.18.41.png (24.73 KiB) Viewed 16177 times
The JSON of the app "Make JSON"
aa
aa
Schermafbeelding 2019-02-27 om 17.18.56.png (60.42 KiB) Viewed 16177 times
Working with: Enfocus Switch, Pitstop Server, Quite Imposing, Kodak Nexpress (max 640mm sheets and 500grs) with most options (HD, Clear, Gold, White, Light-Black and Matt fuser), Polar Mohr D80 (compucut), Multigraf, Heidelberg, GMP, Duplo, Hohner.
sander
Advanced member
Posts: 274
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: JSON with special characters

Post by sander »

Ouch, you posted in scripting. I’m not sure about these 3rd party apps. Do you have the scripting module?
sander
Advanced member
Posts: 274
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: JSON with special characters

Post by sander »

Now I’m thinking of it, try this header, might work:
Content-Type: application/json;charset=utf-8
mart3223
Member
Posts: 28
Joined: Mon May 07, 2018 3:00 pm

Re: JSON with special characters

Post by mart3223 »

I don'y have the scripting module. I have tested with the header "Content-Type: application/json;charset=utf-8" but that doesn't change anything. Can it be a bug in Switch?
Working with: Enfocus Switch, Pitstop Server, Quite Imposing, Kodak Nexpress (max 640mm sheets and 500grs) with most options (HD, Clear, Gold, White, Light-Black and Matt fuser), Polar Mohr D80 (compucut), Multigraf, Heidelberg, GMP, Duplo, Hohner.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: JSON with special characters

Post by gabrielp »

mart3223 wrote: Wed Feb 27, 2019 4:08 pm
gabrielp wrote: Wed Feb 27, 2019 3:48 pm Curious -- does your web server/API get the request? Is it returning an empty response? Or is the request not even getting there?
Yes, it is returning a empty response. No error. If I use a JSON without special characters everything is working fine.
Can you confirm that with the logs from the API server? You could log out the request body received by the API server and see what Switch is doing to the payload.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply