Skip to Content

Unable to do User Registration Service(Cloud Identity Service) from ABAP

Hi,

I have an application in Cloud Identity Service. I have provided the API Authentication for the Service.

I created an SAPUI5 application in HCP and was able to do User Registration using the REST API.

https://help.hana.ondemand.com/cloud_identity/frameset.htm?e6bb70d5e43c4ff89ff700beb82b25fe.html#loio0aa433c741a24df9ac2b3a5faca202de

But when I am calling the same API URL from ABAP Server or from a client like Boomerang, it is giving me the following response

Response Code: 400 - Bad Request - Name ID attribute is required.

But I am providing the name_id and email attributes .

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 08, 2017 at 11:17 AM

    Hi,

    I had provided name_id and email in header parameters of HTTP request- as written in SAP Documentation.

    But that wasn't enough. We need to pass these parameters ( name_id&email ) as body also.

    So in ABAP, apart from passing the parameters as header request, we need to pass those as body using - CL_HTTP_CLIENT->REQUEST->APPEND_CDATA

    Regards

    Sunoj

    Add comment
    10|10000 characters needed characters exceeded

    • Aisurya Puhan Yen Shen, Ben Lim

      Hi Ben,

      Yes, even am using the same to create an User , but my requirement is get the email activation link in the Response , which am not getting via this API " /service/scim/Users " .

      Thanks and Regards,

      Aisurya

  • Jun 19 at 04:38 AM

    Hi Sunoj,

    Do you mind sharing your code snippet for calling the REST api "service/users" in ABAP using CL_HTTP_CLIENT.

    Thanks & Regards,

    Anitha

    Add comment
    10|10000 characters needed characters exceeded

    •   CALL METHOD cl_http_client=>create_by_destination
              EXPORTING
                destination              = 'HCP'
              IMPORTING
                client                   = http_client
      *        EXCEPTIONS
      *          argument_not_found       = 1
      *          destination_not_found    = 2
      *          destination_no_authority = 3
      *          plugin_not_active        = 4
      *          internal_error           = 5
      *          others                   = 6
                    .
            IF sy-subrc <> 0.
      *       Implement suitable error handling here
      *      ENDIF.
      
      CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
           EXPORTING NAME  = 'name_id'
                     VALUE = nameid     
                      .
      
      
       CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
            EXPORTING NAME  = 'email'
                      VALUE = email.    
      
      
       CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
            EXPORTING NAME  = 'first_name'
                      VALUE = first.
      
      
       CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
            EXPORTING NAME  = 'last_name'
                      VALUE = last.
      
      
      CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
           EXPORTING NAME  = '~request_method'
                     VALUE = 'POST'
                      .
      
      
       CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
            EXPORTING NAME  = 'Content-Type'
                      VALUE = 'application/x-www-form-urlencoded'.
      
      
      
      
      CLEAR single.
      CONCATENATE 'name_id=' namid '&email=' mail '&first_name=' FIRST '&last_name=' LAST INTO single.
      
      
      CALL METHOD http_client->REQUEST->append_cdata
        EXPORTING
          data   = w_single   
      *    offset = 0
      *    length = -1
          .
              CALL METHOD http_client->send
                EXCEPTIONS
                  http_communication_failure = 1
                  http_invalid_state         = 2.
      
      
      
      
              CALL METHOD http_client->receive
                EXCEPTIONS
                  http_communication_failure = 1
                  http_invalid_state         = 2
                  http_processing_failed     = 3.
      
      
      
      
      
      
      CALL METHOD http_client->RESPONSE->GET_STATUS
          IMPORTING
            CODE = HTTP_STATUS_CODE
            REASON = STATUS_TEXT.
              result = http_client->response->get_cdata( ).
      
      
              IF  HTTP_STATUS_CODE = 201."Success
      
      
              
      
              ENDIF.
      
      
              CALL METHOD http_client->close
                EXCEPTIONS
                  http_invalid_state = 1
                  OTHERS             = 2.

      Hi,

      You can use the above code - this does the user registration on behaulf.

      Or you can go for the SCIM based API for user creation ( based on your business senario)

      Thank You

      Sunoj Michael