3.7.1 REST API Inquiry Question(s)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

3.7.1 REST API Inquiry Question(s)

Henry Versemann

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

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: 3.7.1 REST API Inquiry Question(s)

Jason Tesser
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 

On Fri, Dec 15, 2017 at 11:53 AM Henry Versemann <[hidden email]> wrote:

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

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAKKUxWcmd2EbhRhoS%3Dc56DN0jUSyydMev0M33kfDC1zifRuzbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: 3.7.1 REST API Inquiry Question(s)

John Michael Thomas
In reply to this post by Henry Versemann
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).


On Friday, December 15, 2017 at 8:53:45 AM UTC-8, newbie23 wrote:

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

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/beae6c4a-b1b6-43fd-8757-13cb62adffe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: 3.7.1 REST API Inquiry Question(s)

Henry Versemann
In reply to this post by Jason Tesser

Thanks Jason.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Jason Tesser
Sent: Friday, December 15, 2017 11:01 AM
To: [hidden email]
Subject: Re: [dotcms] 3.7.1 REST API Inquiry Question(s)

 

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 

 

On Fri, Dec 15, 2017 at 11:53 AM Henry Versemann <[hidden email]> wrote:

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

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--

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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAKKUxWcmd2EbhRhoS%3Dc56DN0jUSyydMev0M33kfDC1zifRuzbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377797F2C077E6ADF8137178AD0B0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: 3.7.1 REST API Inquiry Question(s)

Henry Versemann
In reply to this post by John Michael Thomas

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

 

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

 

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).


On Friday, December 15, 2017 at 8:53:45 AM UTC-8, newbie23 wrote:

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

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/beae6c4a-b1b6-43fd-8757-13cb62adffe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377786D63E902A24187A2DB3AD0B0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: 3.7.1 REST API Inquiry Question(s)

Henry Versemann
In reply to this post by John Michael Thomas

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: [hidden email] [mailto:[hidden email]] On Behalf Of John Michael Thomas
Sent: Friday, December 15, 2017 11:27 AM
To: dotCMS User Group <[hidden email]>
Subject: [dotcms] Re: 3.7.1 REST API Inquiry Question(s)

 

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).


On Friday, December 15, 2017 at 8:53:45 AM UTC-8, newbie23 wrote:

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

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/beae6c4a-b1b6-43fd-8757-13cb62adffe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB3777BAB307BC20DD0245F11AAD0B0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.