Saturday, September 29, 2007

How to use ABAP HTTP_POST

SAP has the function modules HTTP_GET and HTTP_POST to call remote urls. With HTTP_GET one can just had parameters in the URL to send information to the external system. For example, setting the url to


http://myserver.com/mypage?x=1&y=10


sends x=1 and y=10 as parameters to mypage. The problem with HTTP GET is that there is a limit on the ammount of data that can be sent (technically it is unlimited in the new specification, but there are still servers that impose the old limit).

To send large ammounts of data using HTTP one should use the POST method (ABAP function HTTP_POST). To accomplish the same call with HTTP_POST first the length of the data must be calculated


len("x=1&y=10") = 8


then the function must be called with the following parameters


ABSOLUTE_URI http://myserver.com/mypage
REQUEST_ENTITY_BODY_LENGTH 8
REQUEST_ENTITY_BODY x=1&y=10


The function group URL_GENERATION has some data quoting functions to help build valid URLs. Also, the introspector tool is helpful to debug the HTTP calls.

PS. This post was originally in pvl.freezope.org, but that site is down most of the time so I'm moving it here.

Labels: ,

1 Comments:

Anonymous Anonymous said...

hi,

i am trying to use http_post 'cause i've read that http_get has some limitations for lower version of sap. i'm developing a program in sap 4.6D that will need to trigger an external web service but everytime I execute the fm, an error 'Request format is invalid: .' do you have any idea on what could be the problem on this? i passed the abs uri and request entity body as you specified here as well as other tables for return. only, i appended an entry to request_entity_body instead since it requires a table to be passed. is that correct? hope to here from you very soon. many thanks.

regards,
jovee

2:46 AM  

Post a Comment

<< Home