3.7.1 REST API Inquiry Question(s)

8 views
Skip to first unread message

Henry Versemann

unread,
Dec 15, 2017, 11:53:45 AM12/15/17
to dot...@googlegroups.com

I have to search our departments structure for a department name of English/Literature, and because that department name contains a forward slash I’m trying to figure out how to send it properly, since I’m getting back a contentlet for our other department which has the word English in it (English As a Second Language).

 

I’m sending the search to our REST API from an external powershell script.

 

I have already tried replacing the “/” character with a %2F and when I do that in my script (Powershell) code it starts throwing exceptions.

 

I’ve also tried the PowerShell utility [uri]::EscapeUriString($SitePath) and it doesn’t appear to really do anything with it, and the search then still brings back the same wrong contentlet, for the wrong department.

 

So I’m looking for some other way to do it and am continuing to search for a solution.

 

Any suggestions?

 

Thanks for looking.

 

Henry

 

 

 

Jason Tesser

unread,
Dec 15, 2017, 12:01:11 PM12/15/17
to dot...@googlegroups.com
So I know you have been wrestling with this Henry 

As a suggestion I would work outside of Powershell first

Maybe use CURL or some other tool that is more direct access to REST
Monitor your access log and such. 

Then when you have your URLs and POSTs working move to Powershell. Then you will know your REST queries work and can see why it doesn't in Powershell 

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377731D8E9A4E2B98D80AE99AD0B0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
--



3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 
305-900-2001 | Direct: 978.294.9429

John Michael Thomas

unread,
Dec 15, 2017, 12:27:26 PM12/15/17
to dotCMS User Group
So a few thoughts here, hopefully one of these may work for you:

Assuming you're using the content REST API which allows you to use a Lucene query (e.g. `/api/content/query/...` or `/api/content/render/...`):
1. Replace the slash with a Lucene wildcard character (e.g. replace "English/Literature" with "English?Literature").
    * You can also try with `*` instead of `?` (since I'm not sure how easy it will be to escape either of these in Powershell).
2. Use the Lucene AND (`&&`) operator instead of the slash (e.g. "English && Literature").
    * I assume this may cause as many Powershell problems as the slash, but it's possible it's easier to escape.
3. Separate "English" and "Literature", but use the Lucene '+' operator on each to make sure they both are required (e.g. "+English +Literature").

Worst case: Cheat by creating your own page which is essentially your own REST API endpoint.  You can then choose how you specify the search terms in the URL parameters (making sure to use characters that Powershell won't gak on), use Velocity code in the page to construct the correct Lucene query from the URL parameters, and return exactly the data you want in JSON format.  If this sounds like something you want/need to do, let me know and I can give you more info on how to do this, including some Velocity code for getting/displaying the content in JSON format (I'm writing a blog post and document on how to do this, but neither are quite done yet).

Henry Versemann

unread,
Dec 15, 2017, 12:35:45 PM12/15/17
to dot...@googlegroups.com

Thanks Jason.

Image removed by sender.

 

 

3059 Grand Avenue

Suite 410-B

Miami FL 33133

Main: 305-900-2001 | Direct: 978.294.9429

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

Henry Versemann

unread,
Dec 15, 2017, 12:41:18 PM12/15/17
to dot...@googlegroups.com

John,

I will try  the methods you suggested to see what works best.

I have this search working for all of the other department name variations that currently have special characters embedded in them so hopefully

I can quickly find something that works with embedded slashes.

Thanks again for the help.

 

Henry

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

Henry Versemann

unread,
Dec 15, 2017, 1:13:52 PM12/15/17
to dot...@googlegroups.com

John,

 

Your suggestion for using one of the two Lucene wildcard characters (? Or *) has paid off.

I got the asterisk character to work, and it brings back the correct data.

Thanks a bunch for the help.

 

Henry

 

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of John Michael Thomas
Sent: Friday, December 15, 2017 11:27 AM
To: dotCMS User Group <dot...@googlegroups.com>
Subject: [dotcms] Re: 3.7.1 REST API Inquiry Question(s)

 

So a few thoughts here, hopefully one of these may work for you:

--

Reply all
Reply to author
Forward
0 new messages