How to test Sakai REST web services

507 views
Skip to first unread message

Sergio Muriel

unread,
Sep 30, 2017, 3:27:29 PM9/30/17
to saka...@apereo.org

Hi,

Has anybody tested Sakai REST web services with SoapUI? (or any other ws open source tool?)

What kind of authentication can I use and how can I do it?


Thanks

Best Regards,
Sergio Muriel

Sergio Muriel

unread,
Oct 4, 2017, 10:00:45 AM10/4/17
to saka...@apereo.org

Being more specific, when I send a request to one of the services at /direct/describe I keep getting an HTTP 403 access forbidden. So, this SoapUI offers several authorization types, namely: Basic (http), NLTM, SPNEGO/Kerberos, OAuth 1.0 and 2.0. The question is, which one can I use and how can I do it?


Help is appreciated!


From: saka...@apereo.org <saka...@apereo.org> on behalf of Sergio Muriel <serg...@hotmail.com>
Sent: Saturday, September 30, 2017 2:27 PM
To: saka...@apereo.org
Subject: [sakai-dev] How to test Sakai REST web services
 
--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.
To post to this group, send email to saka...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/sakai-dev/.

Earle Nietzel

unread,
Oct 4, 2017, 10:11:28 AM10/4/17
to Sergio Muriel, saka...@apereo.org
Sergio,

When using sakai direct you need will need to login via direct so that an http cookie is established then on subsequent request you will use the cookie in the request which can than identify the request and associate it to the right session.

I've used SOAPUI in the past but I prefer using Postman!

Best,
Earle

Sergio Muriel

unread,
Oct 4, 2017, 5:08:06 PM10/4/17
to saka...@apereo.org

Cookies are fine for browsers (or a browser plugin like Postman), but how about a program like SoapUI or an application that needs to consume those services?



From: Earle Nietzel <ea...@longsight.com>
Sent: Wednesday, October 4, 2017 9:11 AM
To: Sergio Muriel; saka...@apereo.org
Subject: Re: [sakai-dev] Re: How to test Sakai REST web services
 

Jonas Eriksson

unread,
Oct 5, 2017, 2:24:08 AM10/5/17
to Sergio Muriel, saka...@apereo.org

I would try the rest services at /sakai-ws/rest

They are not very RESTful, just a plain http version of the soap services.

There you have the login service which gives back a session that you use in later calls.

 

I have not used them myself, but I guess you have to use the wsdl of the soap services as documentation (try /sakai-ws in the browser)

 

/Jonas

Sergio Muriel

unread,
Oct 5, 2017, 7:25:59 PM10/5/17
to saka...@apereo.org

I tried it but it gave me a "No service was found.":

https://qa11-mysql.nightly.sakaiproject.org/sakai-ws/rest


Thanks for the suggestion anyways but I would like to know if anyone has ever used those /direct/describe services for app2app communication without the need of any human intervention for authentication.



From: saka...@apereo.org <saka...@apereo.org> on behalf of Jonas Eriksson <jonas.e...@umu.se>
Sent: Thursday, October 5, 2017 1:23 AM
To: Sergio Muriel; saka...@apereo.org
Subject: RE: [sakai-dev] Re: How to test Sakai REST web services
 

Steve Swinsburg

unread,
Oct 6, 2017, 1:08:00 AM10/6/17
to Sergio Muriel, sakai-dev
If you are using the /direct web services, then yes, they have been incorporated into mobile apps etc.

Cheers
Steve

To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+unsubscribe@apereo.org.


To post to this group, send email to saka...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/sakai-dev/.

--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.

To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+unsubscribe@apereo.org.


To post to this group, send email to saka...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/sakai-dev/.

--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.

To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+unsubscribe@apereo.org.


To post to this group, send email to saka...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/sakai-dev/.

--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+unsubscribe@apereo.org.

To post to this group, send email to saka...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/sakai-dev/.

--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+unsubscribe@apereo.org.

Jonas Eriksson

unread,
Oct 6, 2017, 7:18:04 AM10/6/17
to Sergio Muriel, saka...@apereo.org

Each endpoint has its own address, see them all at the bottom of the document

https://qa11-mysql.nightly.sakaiproject.org/sakai-ws

 

To login, send a GET to /sakai-ws/rest/login/login?id=userId&pw=password

 

You get back a session as a single string.

Compound values are transformed to xml.

 

Either use soapUI to discover the documentation of the endpoints, or look in the code in the “webservices” module.

Sergio Muriel

unread,
Oct 11, 2017, 4:50:31 PM10/11/17
to sakai-dev

Thank you for your answer Steve. In fact, I need some more information. I am trying to modify the data of a user via direct/ RESTful web services. This is how I am proceeding:


(I have previously set session.parameter.allow=true on my sakai.properties)


I send a POST  request to 

/direct/session.json?_username=admin&_password=admin


and I get an HTTP 201 with a session id like 5046d160-464d-432b-aa49-5b3d4d43d1a6.

So far, everything looks good. Then I send a PUT request to 

/direct/user/{userID}.json?lastName=SomeLastName&_validateSession=true&sakai.session=5046d160-464d-432b-aa49-5b3d4d43d1a6


Then I get an HTTP 204 which according to the direct/user/describe documentation has to have modified the user information; however, when I do a /direct/user/{userID}.json I still see the same lastName.


Raw response example:

============================================================================================================

HTTP/1.1 204 
Set-Cookie: JSESSIONID=5046d160-464d-432b-aa49-5b3d4d43d1a6.Sakai; Path=/; Secure; HttpOnly
X-Frame-Options: SAMEORIGIN
Last-Modified: Wed, 11 Oct 2017 20:17:15 GMT
ETag: 1507753035985
Date: Wed, 11 Oct 2017 20:17:15 GMT
Expires: Wed, 11 Oct 2017 20:27:15 GMT
Cache-Control: public
Cache-Control: max-age=600
Cache-Control: s-maxage=600
x-entity-prefix: user
x-entity-reference: /user/user999
x-entity-url: /user/user999/edit.json
x-entity-format: json
x-sdata-handler: org.sakaiproject.entitybroker.providers.UserEntityProvider
x-sdata-url: /user/user999.json
Location: /user/user999/edit.json
EntityReference: /user/user999
Content-Type: application/json;charset=UTF-8
============================================================================================================

Am I doing what I am supposed to do? Or is there something wrong with this service?


Thank you



Best Regards,
Sergio Muriel



From: saka...@apereo.org <saka...@apereo.org> on behalf of Steve Swinsburg <steve.s...@gmail.com>
Sent: Friday, October 6, 2017 12:07 AM
To: Sergio Muriel
Cc: sakai-dev
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.

Steve Swinsburg

unread,
Oct 12, 2017, 6:38:53 AM10/12/17
to Sergio Muriel, sakai-dev
You may be seeing cached data. Has the data changed in the database?

Cheers
Steve

Sergio Muriel

unread,
Oct 12, 2017, 12:32:32 PM10/12/17
to Steve Swinsburg, sakai-dev

No changes at all. This is my query:

select * from sakai_user where email = .....

Any ideas about what could be wrong?

Thank you.



Best Regards,
Sergio Muriel


From: Steve Swinsburg <steve.s...@gmail.com>
Sent: Thursday, October 12, 2017 5:38 AM

Steve Swinsburg

unread,
Oct 13, 2017, 12:10:51 AM10/13/17
to Sergio Muriel, sakai-dev
Not sure, something could be broken. Anything in the logs? 

Hendrik Steller

unread,
Oct 13, 2017, 7:30:08 AM10/13/17
to saka...@apereo.org, Sergio Muriel
On Thursday, 12. Oktober 2017 18:32:29 CEST Sergio Muriel wrote:
[..]
> Any ideas about what could be wrong?

Yes. No. Well, sort of.
After some trial&error I can at least provide a working solution.
I have created a project with a JAX-RS based Java client which takes care of
the authentication crap so that the (only) implemented example of changing a
user's property like "lastName" becomes

JsonNode readOnly = userService.getUser("internal id");
ObjectNode editable = (ObjectNode) readOnly;
editable.put("lastName", "foobar");
userService.updateUser(editable);

You can find it here:
-> https://github.com/hsteller/sakairesttest


As for what could be wrong:
To quote http://localhost:8080/direct/user/describe:
"Input formats : html, xml, json"

I don't know how "html" as an input format is supposed to work, but the PUT
did work form me when I submitted a JSON object as the request body:

"{\"id\"=\""+userId+"\",\"lastName\"=\"foobar\"}"

Note: using single quotes in the JSON resulted in the same 204 status and no
changes to the data; I guess that is this endpoint's way of saying that it
didn't understand the request's payload, although it says in the
description: "400 if inputs invalid".
(I managed to trigger a 400 by accidentally including invalid characters in
the URL);

Hendrik











> ________________________________
> From: Steve Swinsburg <steve.s...@gmail.com>
> Sent: Thursday, October 12, 2017 5:38 AM
> To: Sergio Muriel
> Cc: sakai-dev
> Subject: Re: [sakai-dev] Re: How to test Sakai REST web services
>
> You may be seeing cached data. Has the data changed in the database?
>
> Cheers
> Steve
>
> On 12 Oct. 2017 07:50, "Sergio Muriel"
> From: saka...@apereo.org<mailto:saka...@apereo.org>
> <saka...@apereo.org<mailto:saka...@apereo.org>> on behalf of Steve
> Swinsburg <steve.s...@gmail.com<mailto:steve.s...@gmail.com>>
> Sent: Friday, October 6, 2017 12:07 AM
> To: Sergio Muriel
> Cc: sakai-dev
> Subject: Re: [sakai-dev] Re: How to test Sakai REST web services
>
> If you are using the /direct web services, then yes, they have been
> incorporated into mobile apps etc.
>
> Cheers
> Steve
>
> On 6 Oct. 2017 10:25 am, "Sergio Muriel"
> <serg...@hotmail.com<mailto:serg...@hotmail.com>> wrote:
>
> I tried it but it gave me a "No service was found.":
>
> https://qa11-mysql.nightly.sakaiproject.org/sakai-ws/rest
>
> Thanks for the suggestion anyways but I would like to know if anyone has
> ever used those
> /direct/describe<https://qa11-mysql.nightly.sakaiproject.org/direct/describ
> e> services for app2app communication without the need of any human
> intervention for authentication.
>
>
> ________________________________
> From: saka...@apereo.org<mailto:saka...@apereo.org>
> <saka...@apereo.org<mailto:saka...@apereo.org>> on behalf of Jonas
> Eriksson <jonas.e...@umu.se<mailto:jonas.e...@umu.se>> Sent:
> Thursday, October 5, 2017 1:23 AM
> To: Sergio Muriel; saka...@apereo.org<mailto:saka...@apereo.org>
> Subject: RE: [sakai-dev] Re: How to test Sakai REST web services
>
>
> I would try the rest services at /sakai-ws/rest
>
> They are not very RESTful, just a plain http version of the soap services.
>
> There you have the login service which gives back a session that you use in
> later calls.
>
>
>
> I have not used them myself, but I guess you have to use the wsdl of the
> soap services as documentation (try /sakai-ws in the browser)
>
>
>
> /Jonas
>
>
>
> From: saka...@apereo.org<mailto:saka...@apereo.org>
> [mailto:saka...@apereo.org<mailto:saka...@apereo.org>] On Behalf Of
> Sergio Muriel Sent: den 4 oktober 2017 23:08
> To: saka...@apereo.org<mailto:saka...@apereo.org>
> Subject: Re: [sakai-dev] Re: How to test Sakai REST web services
>
>
>
> Cookies are fine for browsers (or a browser plugin like Postman), but how
> about a program like SoapUI or an application that needs to consume those
> services?
>
>
>
> ________________________________
>
> From: Earle Nietzel <ea...@longsight.com<mailto:ea...@longsight.com>>
> Sent: Wednesday, October 4, 2017 9:11 AM
> To: Sergio Muriel; saka...@apereo.org<mailto:saka...@apereo.org>
> Subject: Re: [sakai-dev] Re: How to test Sakai REST web services
>
>
>
> Sergio,
>
>
>
> When using sakai direct you need will need to login via direct so that an
> http cookie is established then on subsequent request you will use the
> cookie in the request which can than identify the request and associate it
> to the right session.
>
>
>
> I've used SOAPUI in the past but I prefer using Postman!
>
>
>
> Best,
> Earle
>
>
>
> On Wed, Oct 4, 2017 at 10:00 AM Sergio Muriel
> <serg...@hotmail.com<mailto:serg...@hotmail.com>> wrote:
>
> Being more specific, when I send a request to one of the services at
> /direct/describe<https://qa11-mysql.nightly.sakaiproject.org/direct/describ
> e> I keep getting an HTTP 403 access forbidden. So, this SoapUI offers
> several authorization types, namely: Basic (http), NLTM, SPNEGO/Kerberos,
> OAuth 1.0 and 2.0. The question is, which one can I use and how can I do
> it?
>
>
>
> Help is appreciated!
>
> ________________________________
>
> From: saka...@apereo.org<mailto:saka...@apereo.org>
> <saka...@apereo.org<mailto:saka...@apereo.org>> on behalf of Sergio
> Muriel <serg...@hotmail.com<mailto:serg...@hotmail.com>> Sent:
> Saturday, September 30, 2017 2:27 PM
> To: saka...@apereo.org<mailto:saka...@apereo.org>
> Subject: [sakai-dev] How to test Sakai REST web services
>
>
>
> Hi,
>
> Has anybody tested Sakai REST web services with SoapUI? (or any other ws
> open source tool?)
>
> What kind of authentication can I use and how can I do it?
>
>
>
> Thanks
>
> Best Regards,
> Sergio Muriel
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai Development" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> sakai-dev+...@apereo.org<mailto:sakai-dev+...@apereo.org>.
> To post to this group, send email to
> saka...@apereo.org<mailto:saka...@apereo.org>. Visit this group at
> https://groups.google.com/a/apereo.org/group/sakai-dev/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai Development" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> sakai-dev+...@apereo.org<mailto:sakai-dev+...@apereo.org>.
> To post to this group, send email to
> saka...@apereo.org<mailto:saka...@apereo.org>. Visit this group at
> https://groups.google.com/a/apereo.org/group/sakai-dev/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai Development" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> sakai-dev+...@apereo.org<mailto:sakai-dev+...@apereo.org>.
> To post to this group, send email to
> saka...@apereo.org<mailto:saka...@apereo.org>. Visit this group at
> https://groups.google.com/a/apereo.org/group/sakai-dev/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai Development" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> sakai-dev+...@apereo.org<mailto:sakai-dev+...@apereo.org>.
> To post to this group, send email to
> saka...@apereo.org<mailto:saka...@apereo.org>. Visit this group at
> https://groups.google.com/a/apereo.org/group/sakai-dev/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai Development" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> sakai-dev+...@apereo.org<mailto:sakai-dev+...@apereo.org>.
> To post to this group, send email to
> saka...@apereo.org<mailto:saka...@apereo.org>. Visit this group at
> https://groups.google.com/a/apereo.org/group/sakai-dev/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai Development" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> sakai-dev+...@apereo.org<mailto:sakai-dev+...@apereo.org>.
> To post to this group, send email to
> saka...@apereo.org<mailto:saka...@apereo.org>. Visit this group at
> https://groups.google.com/a/apereo.org/group/sakai-dev/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Sakai Development" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> sakai-dev+...@apereo.org<mailto:sakai-dev+...@apereo.org>.
> To post to this group, send email to
> saka...@apereo.org<mailto:saka...@apereo.org>. Visit this group at
> https://groups.google.com/a/apereo.org/group/sakai-dev/.


Sergio Muriel

unread,
Oct 13, 2017, 12:22:59 PM10/13/17
to Steve Swinsburg, sakai-dev

I've got it! This is because I was using an unnecessary json extension. 

localhost_access_log.txt:


10.10.10.10 - - [13/Oct/2017:11:37:57 -0400] "PUT /direct/user/user999.json?_validateSession=true&sakai.session=a0a8b734-9674-4ada-943b-8bc5c912807d&firstName=foo HTTP/1.1" 204 -

10.10.10.10 - - [13/Oct/2017:11:53:55 -0400] "PUT /direct/user/user999?_validateSession=true&sakai.session=a0a8b734-9674-4ada-943b-8bc5c912807d&firstName=foo&lastName=bar HTTP/1.1" 204 -

Anyways, it never said anything either on the browser or in my catalina.out.  direct/user/describe/ documentation says:

Update Entity URL: PUT /user/:ID: (form)
Response Code Details: 204; 400 if inputs invalid

I was getting a 204 but the entity was not being modified. This can be a bug or inconsistency.


Best Regards,
Sergio Muriel



From: Steve Swinsburg <steve.s...@gmail.com>
Sent: Thursday, October 12, 2017 11:10 PM
Reply all
Reply to author
Forward
0 new messages