Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Viber API Consume Abap

Former Member
0 Kudos

Hello Experts,


I am trying to consume Viber Api through abap to send messages ( https://developers.viber.com/docs/api/rest-bot-api/#send-message) . I have imported certificate in STRUST and restarted ICM but i still get error 500 Native SSL Error .

<html><head><title>Application Server Error</title></head><body>##<H2><b>500 Native SSL error</b></H2><br>##Error is logged with Tag: {000000c1}<br><hr>##Thu May 17 14:14:32 2018###</body></html>##

Here is my coding

Thank you in advance

clear lv_url.
  data lo_http_client type ref to if_http_client.


  cl_http_client=>create_by_url(
    exporting
      url    = 'https://chatapi.viber.com/pa/send_message'
      ssl_id = 'ANONYM'
    importing
      client = lo_http_client
    exceptions
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      others             = 4 ).


  if sy-subrc <> 0.
    return.
  endif.


  call method lo_http_client->request->set_header_field
    exporting
      name  = 'X-Viber-Auth-Token'
      value = 'mytoken'.

  data lv_payload type string.

  lv_payload =
  '{ "receiver":"+mynumber", "min_api_version":1, "sender":{"name":"test","avatar":"http://avatar.example.com"},"tracking_data":"tracking data","type":"text","text":"Hello world!"}'.
  "auth_token":"47cfdca9aa27d36c-18f19b36d0a76b77-200e5e1d98a63134"

  data lv_payload_x type xstring.
  call function 'SCMS_STRING_TO_XSTRING'
    exporting
      text   = lv_payload
    importing
      buffer = lv_payload_x.



  lo_http_client->request->set_method( 'POST' ).
  lo_http_client->request->set_content_type( 'application/json' ).
  lo_http_client->request->set_data( lv_payload_x ).



  lo_http_client->send(
      exceptions
        http_communication_failure = 1
        http_invalid_state        = 2 ).



  lo_http_client->receive(
    exceptions
      http_communication_failure = 1
      http_invalid_state        = 2
      http_processing_failed    = 3 ).



  data lv_response type string.
  lv_response = lo_http_client->response->get_cdata( ).


  e_response = lv_response.

  • SAP Managed Tags:
0 REPLIES 0