1. Frankel David
  2. PowerBuilder
  3. Wednesday, 30 December 2020 10:00 AM UTC

I am posting a request to an API from a server in Greece.

The content reply header is :application/json; charset=windows-1253

When trying to get the data with GetResponseBody all I get is  two unreadable characters.

I have tried using UTF-8 and ANSI but nothing helps.

I installed the Greek language but does not help

On my same computer (even before installing the Greek language) when running the same request in Postman, the reply is ok.

Any help would be appreciated.

d.f.

 

Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Monday, 4 January 2021 08:29 AM UTC
  2. PowerBuilder
  3. # 1

Hi David,

 

Is the current PB version you are using PB 2019? This feature is not supported in PB 2017.

I suggest that you upgrade PB to PB 2019 GA or PB 2019 R2 2353 and try again.

You can refer to the following links for the detail.

https://docs.appeon.com/pb2019/whats_new/ch01s04.html#Enhanced_HTTPClient_object_in_GA

GetResponseBody: supports to encode the data with the charset which is specified by the user in the Content-Type response header; if charset is not specified, this function determines the encoding type based on the BOM header, and then converts the data into UNICODE.

https://docs.appeon.com/pb2019r2/powerscript_reference/ch10s311.html

 

Regards,

 

Comment
  1. mike S
  2. Monday, 4 January 2021 17:47 PM UTC
getresponsebody DOES have an encoding parm:



"A value specifying the encoding type of the string data to be sent: EncodingANSI!, EncodingUTF8!, EncodingUTF16LE!, or EncodingUTF16BE!. If the user sets the encoding charset in the Content-Type request header, this argument will be ignored."



"PowerBuilder should use the response header for determining the character set and not the REQUEST header."

I agree.



if this is not happening (as per what you are seeing), then you should post this as a bug.

  1. Helpful
  1. mike S
  2. Monday, 4 January 2021 17:49 PM UTC
Actually, the help is pretty clear in that it will only use the encoding that was specified in the request header. which is stupid.



  1. Helpful
  1. Mark Lee @Appeon
  2. Tuesday, 5 January 2021 09:17 AM UTC
Hi David & Mike,



Regarding the description of this getResponseBody method, the local PB Help description prevails.

The description on this current web page is incorrect. The correct description should be as follows:

A value specifying the encoding type of the string data to be received: EncodingANSI!, EncodingUTF8!, EncodingUTF16LE!, or EncodingUTF16BE!.

If this argument is set, the encoding charset in the Content-Type response header will be ignored.



We will update the online document. Very sorry for the inconvenience caused!

Currently, this design of PB, unlike Postman, is not quite smart.

We suggest that you can use the Blob argument with GetResponseBody function and see if there’s any difference.

e.g.:

objectname.GetResponseBody ( blob data )



In addition, if you can provide a reproducible PB test case (with PBT / PBL), kindly please report this issue to our ticket system: https://www.appeon.com/standardsupport/newbug so that it can be properly received and tracked.



Regards,
  1. Helpful
There are no comments made yet.
Frankel David Accepted Answer Pending Moderation
  1. Sunday, 3 January 2021 12:57 PM UTC
  2. PowerBuilder
  3. # 2

Miguel thanks for you reply,

I realize that the 2 characters are the BOM which I agree shouldn't be there - but are.

I tried not specifying encoding which didn't help.

But in the end, we moved the actual communication level to c# which had no problem in decoding the characterset to UTF-8.

So for now the problem I solved - but its a pity that PB can't handle such stuff..

Thanks again.

d.f.

 

 

Comment
  1. Miguel Leeuwe
  2. Monday, 4 January 2021 15:38 PM UTC
Ha, glad you could solve it with C#. That's what I've done also for another maybe similar (but not the same) problem when using richtext SaveDocument() as html. If in the process that I have to save it to the DB, recover it, save it to disk and open it as UTF, I'm left with a .tmp file which only contains the same 2 funny character. So now I use Ansi which forces me to encode html in an encoded form. All that stuff I'm doing it using C# too, taking advantage of some html parser package. Reported as https://www.appeon.com/standardsupport/search/view?id=5740.

regards
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 3 January 2021 12:18 PM UTC
  2. PowerBuilder
  3. # 3

Hi,

If you're getting 2 unreadable characters, that's probably the BOM.

I think you shouldn't get a BOM at all if the header encoding returns charset=windows-1253, but I'm not an expert on this.

Have you tried NOT specifying the the encoding in GetResponseBody () ?

What response do your get when running the same request in Postman but on the server instead of your own PC.

regards,

 

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.