10-11-2013 2:23 PM
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.
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
10-11-2013 2:40 PM
Hi Manish,
it does not accept long string, how to pass it.
What is the problem you are facing ?
Thanks,
Ajay Bose
10-11-2013 2:57 PM
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
10-11-2013 3:14 PM
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
10-11-2013 3:51 PM
10-13-2013 3:09 PM
10-14-2013 7:28 AM
Sreenivas,
Thanks for replying , this method will ultimately append field to URL.
URL data type is too short to accept it.
Regards
Manish
10-14-2013 11:02 AM
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.
10-14-2013 1:05 PM
Although it is dynamic , it is not accepting more than 256 , is their any basis setting
Regards
Manish
10-14-2013 2:33 PM
Hi,
Split parameter stream and CONCATENATE that into another string type object and pass that object to url parameter of the method.
Regards,
Sreenivas.
10-14-2013 3:40 PM
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
10-15-2013 7:47 AM
Check the Status message , requested URL is too long even i enforce it while debugging.
Regards
Manish
10-15-2013 7:58 AM
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.
10-15-2013 8:33 AM
/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
10-15-2013 9:34 AM
Hello Mansih,
just a question: do you know the difference between http GET and http POST?
Uwe
10-15-2013 10:02 AM
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
10-15-2013 10:40 AM
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".
10-15-2013 10:46 AM
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' );
10-15-2013 12:29 PM
Well Uwe, i am using oData , in this parameters are passed via URL also.
Regards
Manish
10-15-2013 12:41 PM
Have you tried one of our suggestions yet?
Again: you cannot use Spaces within an URL.