Four Js Development Tools Forum

Discussions by product => GWS => Topic started by: Francois L. on May 05, 2017, 09:48:37 pm



Title: Version 3.0 com.HTTPRequest.doFileRequest
Post by: Francois L. on May 05, 2017, 09:48:37 pm
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.


Title: Re: Version 3.0 com.HTTPRequest.doFileRequest
Post by: Frank G. on May 09, 2017, 09:17:27 am
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


Title: Re: Version 3.0 com.HTTPRequest.doFileRequest
Post by: Francois L. on May 09, 2017, 02:53:43 pm
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


Title: Re: Version 3.0 com.HTTPRequest.doFileRequest
Post by: Frank G. on May 09, 2017, 03:56:40 pm
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