Version 3.0 com.HTTPRequest.doFileRequest

Started by Francois L., May 05, 2017, 09:48:37 PM

Previous topic - Next topic

Francois L.

Gentlemen,

I just saw that method in BDL version 3.0. Before version 3.0, was there another way to send a file through an HTTP POST???

I mean was there a combination of methods that could be used to achieve the same purpose ??

Currently on version 2.41. 

Thanks

Francois

P.S. Obviously my first web service call in BDL with the com methods.

Frank G.

Hi, with a prior version you can use doDataRequest() method and load the file in a BYTE. I should be something like following :

MAIN
DEFINE req com.HTTPRequest
DEFINE resp com.HTTPResponse
DEFINE out,in BYTE
LOCATE out IN MEMORY
LOCATE in IN MEMORY
CALL out.readFile("myfile.jpg")
LET req = com.HTTPRequest.Create("http://your/url")
CALL req.setMethod("POST")
CALL req.doDataRequest(out)
LET resp = req.getResponse()
IF resp.getStatusCode()==200 THEN
   CALL resp.readDataResponse(in)
   CALL in.writeFile("myresponse.jpb")
ELSE
   DISPLAY "ERROR :",resp.getStatusDescription()
END IF
END MAIN

Regards,

Frank

Francois L.

Thank you Frank but that won't fit.

Genero 2.41 does not have the methods described with your solution.
I saw that it starts with version 2.50.
I also read in the server-side documentation that I would probably have to manually code some params such as file boundaries and return line feed in the HTTP forms.

The file that needs to be received is a csv file.


Tanks again.

François

Frank G.

If you want to gain some time. Use version 3.00 :), most of the operations are done automatically, such as setting the correct content-type according to the file extension.

Regards,
Frank