Friday, December 8, 2023

Automating REST Authorization Calls

REST services provided by 3PL partners generally require a two-step process to use their service.  First a call must be made with secret credentials to obtain an authorization token.  Then the auth token is submitted with subsequent requests.

In Manage 2000 REST.SERVICES we can create one REST.SERVICES record to obtain the auth token and then reference it in another REST.SERVICES record:



GetAuthToken accepts JPATH expression parameters to identify the token and the expiration span. It then caches the token for the expiration span and uses the cached version until it expires before going back to the REST service to get a fresh token.

Services like the FEDEX Rates service accept a great many parameters.  These can be specified in the REST.SERVICES record:

A SCREEN.BUILD screen built with matching X_DATA_1 names makes it easy to map the inputs into the RS.COM area for calling the 3PL REST API for information.


The program needs to:

  • Call SUB.MT500 to run the screen
  • Overlay the variables from the screen to the REST common
  • Call REST.SERVICE
  • Parse the result with JPATH
  • Present the results to user, perhaps in the PWS Viewer using SUB.TEXT.OUTPUT.
And the result is a Manage 2000 look and feel function that gets live information from the 3PL REST service: