[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to attach a file in a POST operation



Mario,

You have to know what your provider is expecting. EXAMPLE7, as it states, is mimicking an HTML multipart form (web page that allows a file submission). If this is what you are trying to do, this will work for you with some minor tweaks.

Did you notice that the file being sent was a PDF? So, yes, if that is what you are trying to do this may work.

In any case, http_url_post_stmf is POSTing a file. So that is what you can use.

It sounds like you might be new to HTTPAPI...So, here is a bit about how to find what you are looking for.

HTTPAPI_H member in QRPGLESRC has the prototypes with descriptions of the parameters. Search the member for url_post_stmf and you will find this:

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*  http_url_post_stmf(): Post data to CGI script from stream file     
*                                                                     
*         peURL = url to post to (http://www.blah.com/cgi-bin/etc)    
*    pePostFile = Filename (in IFS) of file to send to http server    
*    peRecvFile = Filename (in IFS) of stream file containing reply   
*    peTimeout  = (optional) give up if no data is received for       
*            this many seconds.                                       
* peUserAgent = (optional) User-Agent string passed to the            
*            server.  Pass the named constant HTTP_USERAGENT          
*            if you want to get the default value.                    
* peContentType = (optional) content type to supply (mainly           
*            useful when talking to CGI scripts)                      
*  peSOAPAction = (optional) string used to specify the action        
*          taken by some SOAP applications.                           
*          - pass *blanks to send an empty SoapAction.                
*          - pass *omit (or don't pass the parm at all) if            
*             you don't want a SoapAction header to be sent.          
*                                                                     
*  Returns  -1 upon failure, 0 upon timeout,                          
*            1 for success, or an HTTP response code                  
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

It explains mostly in English what to use to call the procedure. As you can see, the second parameter is the filename in the IFS to send, the third parameter is the filename in the IFS where the response will be written. This procedure only requires three parameters. So, if you have a file ready to go (doesn't need anything done to it), try this:

Rc = http_url_post_stmf('http://myFriendsWebsite.com/upload/some/file':
                        '/tmp/myfiletoupload.txt':
                        '/tmp/myreplyfile.txt');

When it finishes, DSPF '/tmp/myreplyfile.txt' to see how you did.

If you can explain better what you want to do, we can better point you in the right direction.

 

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mario Salgado
Sent: Monday, April 28, 2014 12:26 PM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: How to attach a file in a POST operation

Hi,
I just saw the post on the EXAMPLE7
You are talking about the '/tmp/http_result.txt'?


In my case I got a file with accurate information to send to the provider, may be a txt file or a pdf file.
This example is about that?

Thanks for your response

Mario Salgado
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------