Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling https:// long url from ABAP code IF_HTTP_CLIENT

CRVMANISH
Contributor
0 Kudos

Hello Experts

I have URL which has around 30 query stream parameters , below is the URL.

my URL data element is of string type , it does not accept long string, how to pass it.

http://xxx.xxx.xx.xx:100/xxxxx.svc/SaveJobNotification?Notificationid='abcxyz'&Priority='CM HIGH' &NotificationType='Corrective Maint.'&SystemStatus=''&UserStatus='Initial'&startdt='20130203'&starttime='122545'&enddt='20130205'&endtime='122545'&CodeGroup='Meter Related Code'&Code='Meter Install' &street='Plot No 87,Sawarkar Nagar'&city='Nagpur'&state='Maharashatra'&country='India'&zipcode='440021'&Telephone='9876543212'&ContactName='dfgdf'&PlannerGroup='dfgd'&DriverID='DRV0000001' &MaintenancePlant='Work 0001'&District='Houston'&Location='USA'&PriorityType='CM'&StatusPro='Profile1'&CodeType='TASK'&CustomerCode='118'&TeamID='TEAM (A)' &Region='Colorado'&CostCenter='Cost Center 1'&ReportedBy='Bhavana'&ReportedOn='20130803'&NotificationName='ererer'&Remark='erter'&CompanyID='CMP0000001'&UserID='USR0000001'

Below is my code , how to pass these parameters

CALL METHOD cl_http_client=>create_by_url

     EXPORTING

       url                = http_url

     IMPORTING

       client             = http_client

     EXCEPTIONS

       argument_not_found = 1

       plugin_not_active  = 2

       internal_error     = 3

       OTHERS             = 4.

http_client->request->set_header_field( name  = '~request_method'

   value = 'POST' ).

* Send the request

   http_client->send( ).

   IF sy-subrc <> 0.

     WRITE : 'Problem'.

   ENDIF.

* Reterive the result

   CALL METHOD http_client->receive

     EXCEPTIONS

       http_communication_failure = 1

       http_invalid_state         = 2

       http_processing_failed     = 3

       OTHERS                     = 4.

   IF sy-subrc <> 0.

     WRITE : 'Problem'.

   ENDIF.

Regards

Manish

19 REPLIES 19

former_member215344
Contributor
0 Kudos

Hi Manish,

it does not accept long string, how to pass it.

What is the problem you are facing ?

Thanks,

Ajay Bose

0 Kudos

Hello Ajay,

http_url is of string type but my URL has more than 255 chars

I want to ask is their any other method to pass parameter data to my http request in the format which i mentioned in url.

Regards

Manish

0 Kudos

Hi Manish,

You can CONCATENATE string literals rite ?

There is a method available in webdynpro CL_WD_UTILITIES=>CONSTRUCT_WD_URL which creates the URL for a webdynpro application. Not sure if there is a method like what you are looking for.

Thanks,

Ajay Bose

0 Kudos

This i cannot use

Regards

Manish

former_member219762
Contributor
0 Kudos

Hi ,

Use   IF_HTTP_CLIENT~APPEND_FIELD_URL .

Regards,

Sreenivas.

0 Kudos

Sreenivas,

Thanks for replying , this method will ultimately append field to URL.

URL  data type is too short to accept it.

Regards

Manish

0 Kudos

Hi,

METHOD cl_http_client=>create_by_url

EXPORTING

       url                = http_url

Here url type is string so it is dynamic .Why it is not accepting more than 256 characters?

Regards,

Sreenivas.

0 Kudos

Although it is dynamic , it is not accepting more than 256 , is their any basis setting

Regards

Manish

0 Kudos

Hi,

Split parameter stream and CONCATENATE that into another string type object and pass that object to url parameter of the method.

Regards,

Sreenivas.

UweFetzer_se38
Active Contributor
0 Kudos

Hi Manish,

I don't think that the length of your request is the problem but the Blanks (Spaces) in your parameters. Parameters must always be URL encoded (spaces for example become "%20").

(for these kind of requests (so many parameters) a POST would be a more proper http method I think)

Best regards

Uwe

0 Kudos

Check the Status message , requested URL is too long even i enforce it while debugging.

Regards

Manish

0 Kudos

Helo

Assuming  client to be an object of class CL_HTTP_CLIENT, you can send whaterver data (field name-value paris, plain data, compressed data, etc.) using this:

  client->request->set_cdata( dummy ).

See report RSHTTP01 for an example.

0 Kudos

/SaveJobNotification?Notificationid=''1234''&Priority=''CM HIGH''&NotificationType=''Corrective Maint.''&SystemStatus=''''&UserStatus=''Initial''&startdt=''20130203'''

*             '&starttime=''122545''&enddt=''20130205''&endtime=''122545''&CodeGroup=''Meter Related Code''&Code=''Meter Install'''             '&street=''Plot No 87,Sawarkar Nagar''&city=''Nagpur''&state=''Maharashatra''&country=''India''&zipcode=''440021''' INTO http_url.

How do i pass this data.

Regards

Manish

0 Kudos

Hello Mansih,

just a question: do you know the difference between http GET and http POST?

Uwe

0 Kudos

Yes Uwe, I have been using it lot these days, this is already post method.

Issue is with only POST not GET Method.

Regards

Manish

0 Kudos

Ok, then you should already know that with a POST you shouldn't pass the parameters via URL but within the message body like Alejandro Mejias said.

On SCN and the ABAP documentation are enough examples on how to code this. Just search for "SET_FORM_FIELD" or "SET_CDATA".

0 Kudos

In the request set content type application/x-www-form-urlencoded, so the request body uses the same format as the query string:

parameter=value&also=another 

something like

CALL METHOD client->request->set_header_field
    EXPORTING
      name  = 'Content-Type'
      value = 'application/x-www-form-urlencoded'.

client->request->set_cdata(  'parameter=value&also=another&everythingconcatenatedas=stringtype' );

0 Kudos

Well Uwe, i am using oData , in this parameters are passed via URL also.

Regards

Manish

0 Kudos

Have you tried one of our suggestions yet?

Again: you cannot use Spaces within an URL.