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

Re: [Ftpapi] I'm obviously missing something ...



Thanks Scott,

I'll look at those options.

I was hoping someone would respond since I have resolved the problem but had no email to reply to!

In the end I had missed something - I had failed to notice just how huge the JWT authorization code was and defined the field too small - in the log I had done a check on what was shown but didn't check far enough down the string to notice the end had dropped off.

As to the content type - the API specification (and all their code samples) call for it so I left it in place.  In the case of all of the POST APIs this will be required so I guess for simplicity they just leave it in all the time.

Thanks for your help.


> On May 4, 2020, at 4:48 PM, Scott Klement <sk@xxxxxxxxxxxxxxxx> wrote:
> 
> Hi Jon,
> 
> I don't know why you are getting the '401' error?  Possibly there's a problem with the Bearer token you're using?  When a login fails, the HTTP protocol typically will just re-send the 401 error.  So if you give a bad userid/password, it'll simply say '401, I need a userid/password' or if you give a bad bearer token, same thing, etc.
> 
> Its not clear why you are adding a 'content-type' here. Content-type is meant to tell the receiving system what sort of data is being sent.  In this example, you are doing a GET request, so it is not sending any sort of data (aside from the URL itself, but content-type does not relate to the URL...)
> 
> I'd also recommend switching to use the newer APIs such as http_string, http_stmf or http_req rather than the old stuff like http_get.  It really shouldn't matter for what you're doing, but as it gets more sophisticated, you'll find the old routines like http_get are difficult to use.
> 
> -SK
> 
> 
> On 5/4/2020 12:00 PM, Jon Paris wrote:
>> Cross-posted to HTTPAPI and WEB400
>> 
>> I just coded up a basic Zoom API request - this is the basic HTTPAPI code:
>> 
>>        url = 'https://api.zoom.us/v2/webinars/' +
>>              %EditC(webinarId: 'X') +
>>              '/tracking_sources';
>> 
>>        headerVars.contentType   = 'application/json';
>> 
>>        headerVars.authorization = 'Bearer mySecrtetCodeGoesHere';
>> 
>>        http_xproc( HTTP_POINT_ADDL_HEADER
>>                  : %paddr(addSpecialHeaders)
>>                  : %addr(headerVars) );
>> 
>>        rc = http_get( url: '/tmp/result.txt' );
>>        if rc <> 1;
>>           http_crash();
>>        endif;
>> 
>> 
>>        Dcl-Proc addSpecialHeaders;
>>        Dcl-Pi *N;
>>          headersToAdd    Varchar(32767);
>>          vars            likeds(headerVars) const;
>>        End-Pi;
>> 
>>        Dcl-C CRLF x'0d25';
>> 
>>        headersToAdd = 'content-type: ' + vars.contentType + CRLF
>>                     + 'authorization: ' + vars.authorization + CRLF;
>>        End-Proc;
>> 
>> 
>> This gives me a "401 - This page requires a user-id & password" error
>> 
>> If I copy/paste the credentials and URL into Insomnia and test it - it works.  The user Id stuff is in the "secret key" bit.
>> 
>> Since I copied and pasted this stuff into insomnia from the RPG stuff I can only assume I missed a step somewhere. But where?
>> 
>> 
>> Jon Paris
> -- 
> _______________________________________________
> Ftpapi mailing list
> Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
> http://scottklement.com/mailman/listinfo/ftpapi

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