Ordering not working in REST API Search

1
+1
-1

Bonita 6.3

Using either of the following URLs in the REST API is returning the same result set in the same order, it should be ordering by name.

    http://localhost:8084/bonita/API/bpm/humanTask?c=10&p=0&f[]=user_id=103&f[]=state=ready&o=name%20DESC

OR

    http://localhost:8084/bonita/API/bpm/humanTask?c=10&p=0&f[]=user_id=103&f[]=state=ready&o=name%20ASC

Why is this not working?

1 answer

1
+1
-1

Hello, you have an error near f parameter, no need to put "[]". I just tested succesfully with these two links:

http://localhost:8081/bonita/API/bpm/humanTask?c=10&p=0&f=user_id=4&f=state=ready&o=name%20DESC
http://localhost:8081/bonita/API/bpm/humanTask?c=10&p=0&f=user_id=4&f=state=ready&o=name%20ASC

Comments

Submitted by jackmatt on Mon, 12/08/2014 - 06:49

OK, but that is not easy to pass with JQuery or any other javascript library, the only way around it is to construct the URL yourself manually. Normally I will be passing a javascript object to JQuery.ajax(). You cannot have the same key twice in an object as this is not valid in javascript. I am passing the following object as the request paylaod.

            data : {
                c:10,
                p:0,
                f: ['user_id=' + currentUserId, 'state=ready'],
                o:name%20DESC
            }

The API expects the payload below, this does not work as the same key is specified in the object twice and will throw a javascript exception.

            data : {
                c:10,
                p:0,
                f: 'user_id='+currentUserId,
                f: 'state=ready',
                o:name%20DESC
            }

I beleive this is a fault in the current REST API. It should be accepting an array.

Submitted by fabio.lombardi on Wed, 12/10/2014 - 14:35

Hi jackmatt,

Have you tried to add a traditional : true in your ajax call?

Something like:

$.ajax('bpm/humanTask',
{
        dataType: "json",
        traditional : true,
        data: {
                c: 10, 
                p: 0, 
                f: ['user_id=' + currentUserId, 'state=ready'],  
                o:name%20DESC
        },
        success: function(data){
            callback(data);
        }
    });

Fabio

Notifications