Skip to Content
0

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

Mar 02, 2017 at 11:54 AM

161

avatar image

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 .

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Sunoj Michael Mar 08, 2017 at 11:17 AM
1

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi @Sunoj,

I'm facing the same issues whereby creating SAPUI5 app in HCP.

I'm not able to create user using the /service/users REST API.

I have tried add in both header and body on the paramters (name_id & email) but the error is still the same error 400Bad Request - Name ID attribute is required.

Any advice on this?

Regards,

Ben

0
Yen Shen, Ben Lim

Hi Ben,

How did you resolve this issue ? Even am facing the same here.

You help will be appreciated .

Thanks,

Aisurya

0

Hi Aisurya,

I'm using another API for my development to create user.

I'm using /service/scim/Users REST API and it's able to create the user in Cloud Identity.

Thanks.

Regards,

Ben

0
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

0
Anitha Shivashankar Jun 19 at 04:38 AM
0

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

Show 1 Share
10 |10000 characters needed characters left 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

0