2006 Dec 12 7:13 PM
URGENT ISSUE -
Hi averyone
I need to make an upload of a file via POST method to a web service.
I have no problems passing the parameters user and password in the header line but i cant add multipart data to post de txt file .
the code im using is :
*create client object
CALL METHOD cl_http_client=>create
EXPORTING
host = host
service = port
scheme = scheme
IMPORTING
client = client.
*Set Header
client->request->set_header_field( name = '~request_uri'
value = path ).
client->request->set_header_field( name = '~request_method'
value = 'POST' ).
client->request->set_header_field( name = '~enctype'
value = 'multipart/form-data' ).
client->request->set_header_field( name = 'Content-Type'
value = 'text/plain').
client->request->set_header_field( name = '~server_protocol'
value = 'HTTP/1.1' ).
Set de los parametros a enviar
client->request->set_form_field( name = 'user'
value = '20295635089').
client->request->set_form_field( name = 'password'
value = '010107').
client->request->set_form_field( name = 'file'
value = 'c:\TB_20295635089_002002_20061212_000001.txt').
DATA: lv_fields TYPE tihttpnvp.
CALL METHOD client->request->get_header_fields
CHANGING
fields = lv_fields.
send and receive
client->send( ).
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
Im getting the following error message
<HTML><TITLE>411 Invalid value for Content-Length header</TITLE><BODY><h1>411 Invalid value for Content-Length header</h1></BODY></HTML>
Ill look forward for some response .
2006 Dec 12 7:55 PM
*create client object
CALL METHOD cl_http_client=>create
EXPORTING
host = host
service = port
scheme = scheme
IMPORTING
client = client.
*Set del Header
client->request->set_header_field( name = '~request_uri'
value = path ).
client->request->set_header_field( name = '~request_method'
value = 'POST' ).
client->request->set_header_field( name = '~enctype'
value = 'multipart/form-data' ).
client->request->set_header_field( name = 'Content-Type'
value = 'text/plain').
client->request->set_header_field( name = '~server_protocol'
value = 'HTTP/1.1' ).
client->request->set_header_field( name = '~Content-Length'
value = '60000' ).
client->request->set_form_field( name = 'user'
value = '20295635089').
client->request->set_form_field( name = 'password'
value = '010107').
client->request->set_form_field( name = 'file'
value = 'c:\TB_20295635089_002002_20061212_000001.txt').
send and receive
client->send( ).
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
2006 Dec 12 8:19 PM
client->request->set_form_field( name = 'file'
value = 'c:\TB_20295635089_002002_20061212_000001.txt').
the above line is the problem.
you have to use gui_upload to upload the data first and then set it to the request object
request->set_cdata
then
request->send
Regards
Raja
2006 Dec 12 8:19 PM
client->request->set_form_field( name = 'file'
value = 'c:\TB_20295635089_002002_20061212_000001.txt').
the above line is the problem.
you have to use gui_upload to upload the data first and then set it to the request object
request->set_cdata
then
request->send
Regards
Raja
2006 Dec 12 9:04 PM
Sorry but i cant take this line out .
File is one of de obligatories parameters ..
if i upload de data and set it to the request object and take out the set_form_file = name = 'file' i get the error : parameter missing FILE .
thanks anyway .. hope you can help me with this.
Regards
Mcol
2006 Dec 13 7:49 AM
i am checking, will get back. however i feel that this may not be possible as the input type ="file" is very strict, you cannot even default file name to this element in normal html programming.
Regards
Raja
2013 Jul 24 6:29 PM
Hi Raja,
I know this is a very old thread but I have the same problem. I need to send a parameter using set_form_field, because If I put it inside a multipart , the web site doesn't recognize it, but using method set_form_field, I don't know what value to pass, because the parameter is type file.
Do you know if there is a way to send a parameter type file , with set_form_field method?
Thansk,
2009 Jun 05 9:07 AM
Hi ,
Even iam facing the same problem...Unexpected request Content-Type header 'application/x-www-form-urlencoded'....
i tried giving the content type properly.Not sure where is the problem.
Can you please help me out.
Meena
2011 Aug 19 6:15 PM
Take the C:\ from that line and then use append_cdata and send.
2011 Dec 12 1:28 PM
Dear all, we are facing same issue, we are not able to send requested file as txt output format.
We sent user & password and input file as string. This is correct? Could you please send us an example?
Thanks in advance,
2012 May 12 9:49 PM
I found a way to make it work, please remove the username and password ARBA service you put: P
2012 Oct 25 7:29 PM
Dear Maxi,
could you please tell us how you send the username and password to ARBA? These are mandatory fields for HTTP Post conection.
Thanks in advance,
Daniela.
2012 Oct 26 3:54 PM
2012 Oct 26 4:17 PM