cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Sending Body to ARIBA with put method in ABAP

ramsthota1986
Explorer
0 Kudos
1,154

Hi Gurus,

I'm new to ABAP world, the requirement I have here is to consume data from ARIBA using Procurement API. Somehow I managed to test the whole process using Postman, But unfortunately I don't have any idea how to do the same using ABAP completely. Below are the activities I did in Postman.

1. Created a Post method in Postman to get access token - Success

2. Created a Post method to create a Template(Requisitions) in Postman Postman by sending the stricture as Body - Success

3. Created a Post method to get refresh Token in Postman Postman - Success

4. Created a Get method to get the template that I have created in point 2 in postman - Success

5. Created a Get method to get the actual data in postman - Success

I'm stuck at point no 2 in ABAP program, Any help is much appreciated. Belo is the body I'm trying to send it ARIBA

Regards,

Rambabu

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Rambau,


in general the way to consume services via HTTP in SAP BTP ABAP Environment is to use the HTTP client API CL_WEB_HTTP_CLIENT. There are different ways to instantiate it with the correct configuration, which are described here.
Constructing a request body can be done in different ways, but all of them involve the HTTP request, which you can get from your client using if_web_http_client~get_http_request( 😞
DATA(lo_client) = cl_web_http_client_manager=>create_by_http_destination( lo_dest ).
DATA(lo_request) = lo_client->get_http_request(  ).

On that HTTP request you can then use setter methods to set the body of the request:
lo_request->set_text( '{"a": "b"}' ).

To convert ABAP structures to JSON, you can e.g. use /UI2/CL_JSON as described in this blog. The result can then be used as the body of the HTTP request.
Finally the request can be sent:
DATA(lo_response) = lo_client->execute( if_web_http_client=>post ).

Hope this helps.
Best Regards,Thomas