Cant get HTTPAPI to work

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
dirthawger
Posts: 4
Joined: Wed Mar 29, 2023 3:50 pm

Cant get HTTPAPI to work

Post by dirthawger »

Hey everyone,

I'm having an issue getting HTTPAPI to work on our system. I have everything installed and in LIBHTTP. However, I can't even access any of the code because I keep getting an RNF0273 error, "Compiler not able to open the /COPY or /INCLUDE file; directive ignored." Here is some of my code:

Code: Select all

 ctl-opt option(*nodebugio) dftactgrp(*no) bnddir('LIBHTTP/HTTPAPI');
    
          dcl-f APITEST01D workstn indds(indicators);
    
          dcl-ds indicators len(99);
            EXIT ind pos(7);
          end-ds;
    
          dcl-pr cmd extpgm('QCMDEXC');
            cmd char(200) const;
            len packed(15:5) const;
          end-pr;
            
          dcl-s url    varchar(100);
          dcl-s header varchar(100);
          
          /copy qrpglesrc,httpapi_h
          
Have we somehow installed it wrong or am I missing a setting? It will compile without /copy directive so I'm guessing the bnddir is correct. I'm a fairly new RPGLE programmer so if someone could help that'd be great.
dirthawger
Posts: 4
Joined: Wed Mar 29, 2023 3:50 pm

Re: Cant get HTTPAPI to work

Post by dirthawger »

I apologize for not checking first, but I'm using miworkplace as my IDE, for some reason I can't compile it in the IDE but it compiles successfully on the green screen.
vhamberg
Posts: 13
Joined: Thu Jul 29, 2021 1:33 am

Re: Cant get HTTPAPI to work

Post by vhamberg »

This sounds like a library list problem - you need to find how to set the library list in MIWorkplace for compilations. We don't use it here, so I don't know where to look.

Anyhow, welcome to the wonderful world of RPGLE!

Vern
dirthawger
Posts: 4
Joined: Wed Mar 29, 2023 3:50 pm

Re: Cant get HTTPAPI to work

Post by dirthawger »

Yea I got that part covered and it recognizes the library and I can see all the procedures in my spooled file but I still can't get a simple http_get program to compile. Says *RNF0637 30 1 An operand was expected but was not found; specification is
ignored.

Code: Select all

ctl-opt option(*nodebugio) dftactgrp(*no) bnddir('HTTPAPI')
              actgrp('HTTPAPI');

          dcl-f APITEST01D workstn indds(indicators);

          dcl-ds indicators len(99);
            EXIT ind pos(7);
          end-ds;

          dcl-pr cmd extpgm('QCMDEXC');
            cmd char(200) const;
            len packed(15:5) const;
          end-pr;

          dcl-s URL    varchar(100) inz('http:///alpha.sportssouth.biz/+
                _roman/test_api.php?NUMBER_IN=12345');
                
          dcl-s header varchar(100);
          dcl-s rc int(10);
          dcl-s msg varchar(52);
          dcl-s status int(5);

          /copy qrpglesrc,httpapi_h


          dow not EXIT;

            exfmt scrn1;
            
            callp http_debug(*on);
            
            rc = http_url_get(:URL:'/tmp/api_test.txt');
            
            if rc <> 1;
              callp http_crash;
            endif;
            
            callp cmd('DSPF ''/tmp/api_test.txt''': 200);
            
            if EXIT = *on;
              leave;
            endif;

          enddo;


           *inlr = *on;
I dunno, thinking of just trying to do it with the SQL HTTPGETCLOB, but HTTPAPI looked a lot easier
jonboy49
Posts: 206
Joined: Wed Jul 28, 2021 8:18 pm

Re: Cant get HTTPAPI to work

Post by jonboy49 »

You have a spurious colon in front of URL - it should be:

Code: Select all

rc = http_url_get(URL:'/tmp/api_test.txt');
I just noticed that you also have an extra / in the URL you are calling. Which by the way won't work for me either
dirthawger
Posts: 4
Joined: Wed Mar 29, 2023 3:50 pm

Re: Cant get HTTPAPI to work

Post by dirthawger »

Much appreciated for the responses, but I finally figured out the problem. I checked the version of HTTPAPI on our system and it was from 2014. Installed new HTTPAPI and so far everything works as it should. Spent about 8 hours on this today only to try this within the last 45 mins.
Post Reply