abaplint / abaplint-sci-client

ABAP part for running abaplint on ABAP backend
MIT License
38 stars 20 forks source link

API request failed [500]: unsupported charset "ISO-8859-1" #231

Closed BlackmanCC closed 3 years ago

BlackmanCC commented 3 years ago

When I run the sci check againt abaplint backend. I get the error:

API request failed [500]: unsupported charset "ISO-8859-1"

Our System is an 740 non-unicode system.

Do you have ideas how I can fix this?

larshp commented 3 years ago

this is when calling the API provided by https://github.com/abaplint/abaplint-sci-server ?

BlackmanCC commented 3 years ago

yes, I am running the API in a docker container on our internal linux server.

larshp commented 3 years ago

is the source ABAP system running unicode?

BlackmanCC commented 3 years ago

no. like I said the system is non-unicode. We will switch to unicode system in the 1st quarter of next year

larshp commented 3 years ago

okay, I missed that part 😄

as far as I remember, there is some way to set the encoding by the http client, need it somewhere around https://github.com/abaplint/abaplint-sci-client/blob/master/src/zcl_abaplint_backend_api_agent.clas.abap#L131

larshp commented 3 years ago

iv_payload must be converted to UTF8, and then use set_data instead, plus set charset http header field

BlackmanCC commented 3 years ago

found this https://codezentrale.de/abap-http-client-anfrage-von-xml-daten/

BlackmanCC commented 3 years ago

I think, header field could be set by

     o_client->request->set_header_field( name  = 'Content-Type'
                                          value = 'text/xml; charset=utf-8' ).

but, how to convert iv_payload to UTF8?

larshp commented 3 years ago

call ZCL_ABAPGIT_CONVERT=>STRING_TO_XSTRING_UTF8

BlackmanCC commented 3 years ago

I should only convert the contents of iv_payload before building the json, right?

I could do it in ZCL_ABAPLINT_BACKEND->BASE64_ENCODE?

BlackmanCC commented 3 years ago

this not works for now:

 API request failed [500]: [abaplint] JSON5: invalid
character '�' at 1:1 ()
larshp commented 3 years ago

whats your code in the client?, it should be something like,

    IF iv_method = 'POST' AND iv_payload IS NOT INITIAL. " OR PUT ... maybe in future
      li_client->request->set_data( ZCL_ABAPGIT_CONVERT=>STRING_TO_XSTRING_UTF8( iv_payload ) ).
      li_client->request->set_header_field( name  = 'Content-Type' value = 'application/json; charset=utf-8' ).
    ENDIF.
larshp commented 3 years ago

but yea, hmm, there might be multiple places that needs changing

BlackmanCC commented 3 years ago

I will look into it tomorrow, but I will need some of your help for sure. I am currently getting slowly better into that things ;-)

larshp commented 3 years ago

see https://github.com/abaplint/abaplint-sci-client/pull/232

BlackmanCC commented 3 years ago

will try it out thanks a lot

BlackmanCC commented 3 years ago

seems to work now. It get LINT_* errorcodes now.

Thank you very much!

larshp commented 3 years ago

fixed, closing