Bryan Schmiedeler
Bryan Schmiedeler

Reputation: 3127

Xpages to call Rest service with auth Token

I need to call some APIs in a Oracle app called Taleo. I have the documentation and was able to get a my calls to work in a REST plugin in Firefox and in a REST Mac Client app,"Paw".

I first have to send credentials to get a auth Token cookie:

https://chj.tbe.taleo.net/chj06/ats/api/v1/login?orgCode=XXXXXXS&userName=XXXXX&password=XXXXXX

If I call this then I receive the authToken [webapi2=numbers].

Then I can use essentially the same URL to POST,GET,PUT,DELETE etc. to different objects, for example a GET to

https://chj.tbe.taleo.net/chj06/ats/api/v1/object/location

with JSON in the body for creating a location.

I think I would like to write a java agent (so it can be schedule) to, for example, to interrogate the data on my system and then create, update, delete as appropriate on the remote system.

I am much more comfortable using LotusScript/SSJS and the built in Rest controls, but probably should take the plunge and do this in Java, but where should I start?

Upvotes: 3

Views: 517

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

I'd go with an Java agent as you want to run your code in background.

Use Java's native HTTP classes

  • java.net.HttpURLConnection and
  • javax.net.ssl.HttpsURLConnection

for HTTP connection. You can find an easy example here as a starting point.

Alternatively you could use more comfortable APIs like Apache's HTTPClient.

If you want/have to stay with LotusScript then you could create a Java class which realizes all HTTP connections and instantiate the class in LotusScript agent per LS2J.
If you have a Windows Domino server then you could use WinHttpRequest with CreateObject() and stay with pure LotusScript.

Upvotes: 3

Related Questions