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

Re: [Ftpapi] HTTPAPI - PUT & DELETE Method



Hi,
It is possible to use DELETE or PUT with the latest version using 'http_req', here an example:

      * EXAMPLEXX:                                                            
      * ----------                                                            
      *  Try to DELETE Google.                                                
      *                                                                       
     H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')                          
                                                                              
     D/copy qrpglesrc,httpapi_h                                               
                                                                              
     D rc              s             10I 0                                    
                                                                              
      /free                                                                   
        http_debug(*on);                                                      
                                                                              
        //                                                                    
        // This example uses http_req(), which is similar to                  
        // http_stmf() from the previous examples, except:                    
        //   - data can be sent from either a stmf or a string                
        //   - data can be received into either a stmf or a string            
        //   - no error message is sent, instead there's a "return code"      
        //       (or 'rc' as I like to abbreviate it)                         
        //                                                                    
        // There are two parameters each for the data to receive and          
        // the data to send, but you can only use one of each.                
        //                                                              
                                                                        
        rc = http_req( 'DELETE'                                         
                     : 'http://www.google.com'                          
                     : '/tmp/response.html'       // File to receive    
                     : *omit                      // String to receive  
                     : *omit                      // File to send       
                     : *omit );                   // String to send     
                                                                        
        *inlr = *on;                                                    


The request sent:
DELETE / HTTP/1.1       
Host: www.google.com    
User-Agent: http-api/1.39

And the response:
HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD
...

Roberto.





Il 30/04/2019 23:30, Jim Wong ha scritto:
Hi,

I have a need to interface IBM i data with an e-commerce site (Shopify). The requirement covers GET, POST, PUT and DELETE methods. However, PUT & DELETE is not supported in current version 1.39. 

The current version whilst it has hooks to support PUT and DELETE, the request Type parameter from HTPPAPI command does not flow through to HTTPAPIR4 service program. Instead, the GET and POST method is hard-coded.

With minimal changes I completed a proof of concept to successfully PUT and DELETE. I simply replaced the hard-coded method with a variable (HTTPAPIR4) and used debug to change POST to PUT or DELETE.

I’m reaching out to our HTTPAPI community to see if there is an enhanced version of HTTPAPI where PUT and DELETE is supported. If available, how do we go about getting these changes into the next version so our user community can all benefit. 

Best regards,
Jim Wong

NAVAN AUSTRALIA PTY LTD
Email: jim.wong@xxxxxxxxxxxx






-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi