on 2021 Mar 05 6:36 AM
Hello Community,
I am trying to set up a http request from abap against an external server.
The Request is a Post request which hast to be the exact Content-Type 'application/jose+json'.
My abap http client is setting the header field perfectly well but SAP seems to be sending:
content-Type: "application/jose+jason; charset=utf-8".
which conflicts with the check on server side I am sending it to.
I already found a sap note which wants me to update my REST client.
https://launchpad.support.sap.com/#/notes/2456232/E
So it seems to be a common problem
The problem is I only get .SCA files and I don't get how to get them into my ABAP stack SAP System.
My setup is:
Component Release SP-Level Support Package
SAP_BASIS 752 0006 SAPK-75206INSAPBASIS
SAP_ABA 752 0006 SAPK-75206INSAPABA
SAP_GWFND 752 0006 SAPK-75206INSAPGWFND
SAP_UI 752 0009 SAPK-75209INSAPUI
ST-PI 740 0013 SAPK-74013INSTPI
SAP_BW 752 0006 SAPK-75206INSAPBW
UIBAS001 300 0006 SAPK-30006INUIBAS001
Thank you for anything that gets me closer to a solution.
Regards,
Robin
Request clarification before answering.
To avoid charset=UTF-8
I am referencing variables from your code for you to better understand, just add below code
lo_client_acct->request->suppress_charset ( supress = abap_true ).
Regards,
Ajinkya Chothave
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I'm running in the same problems 😞
Did anyone find a solution for this? Running cUrl as command is no proper solution I think 😞
best regards
Meex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thank you for responding!
Here is some code I actually use. Very much simplified for showing the communication part.
REPORT zrk_test_013.
DATA: lo_client_dir TYPE REF TO if_http_client.
DATA: lo_client_nonce TYPE REF TO if_http_client.
DATA: lo_client_acct TYPE REF TO if_http_client.
DATA: lv_httpcode TYPE i.
DATA: lv_reason TYPE string.
DATA lv_response_acct TYPE string.
DATA lo_rest_client_acct TYPE REF TO cl_rest_http_client.
DATA lo_response_acct TYPE REF TO if_rest_entity.
DATA lo_request_acct TYPE REF TO if_rest_entity.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = 'https://testingjsonposts0987.requestcatcher.com/'
* proxy_host =
* proxy_service =
* ssl_id =
* sap_username =
* sap_client =
* proxy_user =
* proxy_passwd =
IMPORTING
client = lo_client_acct
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
FORMAT INVERSE ON COLOR 6. FORMAT INVERSE ON COLOR 6.
WRITE: / 'cl_http_client=>create_by_url' . FORMAT COLOR OFF INVERSE OFF.
ENDIF.
IF lo_client_acct IS BOUND.
* Instantiate REST client
CREATE OBJECT lo_rest_client_acct
EXPORTING
io_http_client = lo_client_acct.
DATA lv_post_data TYPE string.
DATA lv_con_len TYPE string.
lo_client_acct->request->set_method( if_http_request=>co_request_method_post ).
lv_post_data = '{ Json example data }'. " For showing purpose only.
lo_request_acct = lo_rest_client_acct->if_rest_client~create_request_entity( ).
lo_request_acct->set_content_type( iv_media_type = 'application/jose+json' ).
lo_request_acct->set_header_field( iv_name = 'content-encoding'
iv_value = 'gzip' ).
lo_client_acct->request->set_version( '1001' ).
lo_client_acct->request->set_cdata( lv_post_data ).
lv_con_len = lo_request_acct->get_content_length( ).
lo_request_acct->set_header_field( iv_name = if_http_header_fields=>content_length
iv_value = lv_con_len ).
* Debugginginformation
DATA(x01) = lo_request_acct->get_header_fields( ).
* Send the HTTP request
CALL METHOD lo_client_acct->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5.
IF sy-subrc <> 0.
FORMAT INVERSE ON COLOR 6.
WRITE: / 'lo_client_acct->send'. FORMAT COLOR OFF INVERSE OFF.
ENDIF.
* HTTP call receive
CALL METHOD lo_client_acct->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
FORMAT INVERSE ON COLOR 6.
WRITE: / 'lo_client_acct->receive'. FORMAT COLOR OFF INVERSE OFF.
ENDIF.
* get status of the response
CALL METHOD lo_client_acct->response->get_status
IMPORTING
code = lv_httpcode
reason = lv_reason.
ENDIF.<br>Maybe is should change the "Content-Encoding" header to something different?
If I use
lo_client_acct->request->set_data( 'data' ). "binary
*insted of
lo_client_acct->request->set_cdata( 'data' ). "stringThe ";charset=utf-8" string on my Content-Type header disapears but i cant send the data as binary which ist intended in this method.
If I use an empty body, SAP sets the Content-Type correctly but when i put some characters in it immediately sets the charset value in the same field.
Best regards,
Robin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The note you're looking at is only relevant for XI (SAP Process Orchestration - PI), so that note is not going to solve your problem I guess.
Can you share at least a code snippet to see how you're sending the HTTP requests from ABAP?
Best regards,
Geert-Jan Klaps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.