Skip to Content
0
Jan 10, 2023 at 01:39 PM

Failed to resolve access token variable oauthToken ABAP

138 Views Last edit Feb 02, 2023 at 01:33 AM 2 rev

Hi ,

i have written code to access REST api through ABAP code but getting error Failed to resolve access token variable oauthToken

please advise the solution

Thanks

  cl_http_client=>create_by_url(<br>  EXPORTING<br>    url                = lv_deed_url<br>  IMPORTING<br>    client             = lo_http_client<br>  EXCEPTIONS<br>    argument_not_found = 1<br>    plugin_not_active  = 2<br>    internal_error     = 3<br>    ).<br>  IF sy-subrc IS NOT INITIAL.<br>* Handle errors<br>  ENDIF.<br>  lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.<br>* lo_http_client->request->set_method( 'POST' ).<br>  CALL METHOD lo_http_client->request->set_header_field<br>    EXPORTING<br>      name  = '~request_method'<br>      value = 'GET'. "'POST'.<br>  CALL METHOD lo_http_client->request->set_header_field<br>    EXPORTING<br>      name  = 'content-type:'<br>      value = 'application/x-www-form-urlencoded'.<br>  CALL METHOD lo_http_client->request->set_header_field "We pass header and value<br>    EXPORTING<br>      name  = 'TokenClienteCert:'<br>      value = ls_data-access_token.<br>  CALL METHOD lo_http_client->request->set_form_field<br>    EXPORTING<br>      name  = 'grant_type'<br>      value = 'password'.<br>  CALL METHOD lo_http_client->request->set_form_field<br>    EXPORTING<br>      name  = 'username'<br>      value = 'XXXXXXX'.<br>  CALL METHOD lo_http_client->request->set_form_field<br>    EXPORTING<br>      name  = 'password'<br>      value = 'XXXXXXX'.<br>  CALL METHOD lo_http_client->send<br>    EXCEPTIONS<br>      http_communication_failure = 1<br>      http_invalid_state         = 2<br>      http_processing_failed     = 3<br>      OTHERS                     = 4.<br>  CALL METHOD lo_http_client->receive<br>    EXCEPTIONS<br>      http_communication_failure = 1<br>      http_invalid_state         = 2<br>      http_processing_failed     = 3<br>      OTHERS                     = 4.<br><br><br>call method lo_http_client->response->get_status<br>  importing<br>    code   = lv_code<br>    reason = lv_reason.<br><br>*** Read the result<br>clear lv_result .<br>data(lv_result_post) = lo_http_client->response->get_cdata( ).<br>