This page requires a user-id & password

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.)
Post Reply
Posts: 1
Joined: Wed Jan 26, 2022 9:12 pm

This page requires a user-id & password

Post by markflores1960 »

Trying to get a FEDEX token to eventually get Tracking by tracking number API. This is the code I am using
HTTP_Debug(*On : %Trim(@IFSError));

postString =
'grant_type=client_credentials' +
'&client_id=' + %Trim(ClientId) +
'&client_secret=' + %Trim(ClientSecret);


rc = http_post(""
: %Addr(postString) + 2
: %Len(postString)
: @IFSResponse
: 'application/x-www-form-urlencoded' );
I keep getting userid & password required. This works in POSTMAN just using my client credentials.
Scott Klement
Site Admin
Posts: 236
Joined: Sun Jul 04, 2021 5:12 am

Re: This page requires a user-id & password

Post by Scott Klement »

Hi Mark,

This error typically means that you need to send a userid/password to log into the site. This is normally done by setting authentication credentials prior to making your POST request. in HTTPAPI, they are set with the http_setAuth() subprocedure.

Code: Select all

http_setAuth(HTTP_AUTH_BASIC: 'myUserId': 'myPassword');
That said, you have also mentioned that it works from PostMan .. do you specify login credentials (in addition to the client_credentials form data) when you use that? If not, then the above may not be correct for your situation.

The other thing I noticed about your request is that you're not encoding the ClientId or ClientSecret which means that if it contains any characters that have special meaning, you will have problems. I would not expect the problem to be "This page requires a user-id & password", but... who knows? I am not familiar with FedEx's APIs, so I don't know how they do things.

Regardless of whether its the current problem or not, you really should be encoding your data properly. You may not happen to have any special characters today, but if you don't encode them, it may bite you in the future. You can encode your data like this:

Code: Select all

postString = 'grant_type=client_credentials' +
           + '&client_id=' + http_urlEncode(%Trim(ClientId)) +
           + '&client_secret=' + http_urlEncode(%Trim(ClientSecret)); 
If that doesn't help, then please provide the output of http_debug().
Post Reply