Skip to Content

CL_HTTP_CLIENT->CREATE_BY_DESTINATION 403 Forbidden

Hi All,

i was searching for answers and saw many times this problem, but with diffrent solutions.

I tried them but without success.

I do a request to a json api for credit card payment (six saferpay json api).

If i build the request in postman and send this, then i get a answer with the url for the six payment page.

In SAP i created first a the destination with the credentials and without the path.

Because the path can be different.

The SSL Certificates are downloaded and "installed" in the trust.

Then in did the Abap coding.

The strange thing is that i get a 403 forbidden back.

I found a hint it could be that the problem is the cookie property, i set now the property, but still i have the problem. Has somebody a hint?

Thanks a lot,

kind regards

Alex

Here my ABAP Coding:

   cl_http_client=>create_by_destination(
    EXPORTING
      destination              = 'SIX_PAYMENT'    " Logical destination (specified in function call)
    IMPORTING
      client                   = lo_http_client    " HTTP Client Abstraction
    EXCEPTIONS
      argument_not_found       = 1
      destination_not_found    = 2
      destination_no_authority = 3
      plugin_not_active        = 4
      internal_error           = 5
      OTHERS                   = 6
  ).
  
  CREATE OBJECT lo_rest_client
     EXPORTING
       io_http_client = lo_http_client.
   lo_http_client->request->set_version( if_http_request=>co_protocol_version_1_0 ).
   IF lo_http_client IS BOUND AND lo_rest_client IS BOUND.
     lv_url = '/api/Payment/v1/PaymentPage/Initialize'.
     cl_http_utility=>set_request_uri(
       EXPORTING
         request = lo_http_client->request    " HTTP Framework (iHTTP) HTTP Request
         uri     = lv_url                     " URI String (in the Form of /path?query-string)
     ).


     lo_http_client->propertytype_accept_cookie  = lo_http_client->co_enabled.


* ABAP to JSON
     DATA: json_req TYPE zcm_oanml_req_header.


      json_req-REQUESTHEADER-SPECVERSION = '1.9'.
      json_req-REQUESTHEADER-CUSTOMERID = 'XXXXXX'.
      json_req-REQUESTHEADER-REQUESTID = '1234567'.
      json_req-REQUESTHEADER-RETRYINDICATOR = '0'.

      json_req-TERMINALID = 'XXXXXXXX'.
      json_req-PAYMENT-AMOUNT-value = '1'.
      json_req-PAYMENT-AMOUNT-currencycode = 'CHF'.
      json_req-PAYMENT-ORDERID = '1234567'.
      json_req-PAYMENT-DESCRIPTION = 'Studiengebühr'.

DATA lr_json_serializer   TYPE REF TO cl_trex_json_serializer.


CREATE OBJECT lr_json_serializer  EXPORTING  data = json_req.
lr_json_serializer->serialize( ).
lv_body = lr_json_serializer->get_data( ).


     DATA: lo_json        TYPE REF TO cl_clb_parse_json,
           lo_response    TYPE REF TO if_rest_entity,
           lo_request     TYPE REF TO if_rest_entity,
           lo_sql         TYPE REF TO cx_sy_open_sql_db,
           status         TYPE  string,
           reason         TYPE  string,
           response       TYPE  string,
           content_length TYPE  string,
           location       TYPE  string,
           content_type   TYPE  string,
           lv_status      TYPE  i.
* Set Payload or body ( JSON or XML)
     lo_request = lo_rest_client->if_rest_client~create_request_entity( ).
     lo_request->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).


     lo_request->set_header_field( iv_name = 'Accept'
                                   iv_value = 'application/json' ).


     lo_request->set_string_data( lv_body ).


	 * POST
     lo_rest_client->if_rest_resource~post( lo_request ).
* Collect response
     lo_response = lo_rest_client->if_rest_client~get_response_entity( ).
     http_status = lv_status = lo_response->get_header_field( '~status_code' ).
     reason = lo_response->get_header_field( '~status_reason' ).
     content_length = lo_response->get_header_field( 'content-length' ).
     location = lo_response->get_header_field( 'location' ).
     content_type = lo_response->get_header_field( 'content-type' ).
     response = lo_response->get_string_data( ).
     ENDIF.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Aug 23, 2018 at 01:28 PM

    The Problem was the SSL Certificat.

    You have to be careful, in the ndestination u can choose whiche type of ssl certificat you need.

    Its needed that you choose the anonymus ssl certificat.

    If u not do this, the certification from sap will be send as authentification and then six returns 403 forbidden, in this situation thats true...

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.