4

I need to create a fairly complex query string in Restangular.

http://vdmta.rd.mycompany.net//people?anr=Smith&attrs=givenName,displayName,name,cn

How do I do this?

So far I am OK getting as far as ?anr=Smith using this:

return Restangular.all('/people').getList({anr:searchTerm});

The last part attrs=x,y,x lets me control which attributes I want back in the search and could change per request I make.

Any advice appreciated.

Regards

i

1 Answer 1

5

You should be able to simply add another query parameter where the value is your comma separated list of attributes.

var attributes = ['givenName' , 'displayName']; // attributes you require for the request
var attributesAsString = attributes.join();

return Restangular.all('/people').getList({
    anr : searchTerm,
    attrs: attributesAsString
});
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Is attributes an array here? Or do I have to build the comma separated list and pass it in as a string?
You could easily provide an array and convert it into a comma separated string (it looks like a comma separated string is what you need, right?). Updated the answer to show. Simply using join().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.