You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by l vic <lv...@gmail.com> on 2019/01/31 21:42:31 UTC

expression failure in URL concatenation?

I am using processor group variable as base part of my URL:
REST_URL=http://localhost:8080/nifi-api

I am trying to append second part of URL in InvokeHTTP regardless if
REST_URL ends with '/', or not so that concatenation of "
http://localhost:8080/nifi-api/", or "http://localhost:8080/nifi-api" with
"resources" return the same URL: "http://localhost:8080/nifi-api/resources":

*${${REST_URL}:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}*


But the expression always appends '/', so in the first case I end up
with *"http://localhost:8080/nifi-api//resources
<http://localhost:8080/nifi-api//resources>"*... Any idea where the error
is?

Thank you,

Re: expression failure in URL concatenation?

Posted by l vic <lv...@gmail.com>.
No

On Thu, Jan 31, 2019 at 4:48 PM James Srinivasan <ja...@gmail.com>
wrote:

> Out of interest, does the URL containing the double slash work?
>
> On Thu, 31 Jan 2019, 21:42 l vic <lvic4594@gmail.com wrote:
>
>> I am using processor group variable as base part of my URL:
>> REST_URL=http://localhost:8080/nifi-api
>>
>> I am trying to append second part of URL in InvokeHTTP regardless if
>> REST_URL ends with '/', or not so that concatenation of "
>> http://localhost:8080/nifi-api/", or "http://localhost:8080/nifi-api"
>> with "resources" return the same URL: "
>> http://localhost:8080/nifi-api/resources":
>>
>>
>> *${${REST_URL}:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}*
>>
>>
>> But the expression always appends '/', so in the first case I end up with *"http://localhost:8080/nifi-api//resources
>> <http://localhost:8080/nifi-api//resources>"*... Any idea where the
>> error is?
>>
>> Thank you,
>>
>>
>>

Re: expression failure in URL concatenation?

Posted by James Srinivasan <ja...@gmail.com>.
Out of interest, does the URL containing the double slash work?

On Thu, 31 Jan 2019, 21:42 l vic <lvic4594@gmail.com wrote:

> I am using processor group variable as base part of my URL:
> REST_URL=http://localhost:8080/nifi-api
>
> I am trying to append second part of URL in InvokeHTTP regardless if
> REST_URL ends with '/', or not so that concatenation of "
> http://localhost:8080/nifi-api/", or "http://localhost:8080/nifi-api"
> with "resources" return the same URL: "
> http://localhost:8080/nifi-api/resources":
>
>
> *${${REST_URL}:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}*
>
>
> But the expression always appends '/', so in the first case I end up with *"http://localhost:8080/nifi-api//resources
> <http://localhost:8080/nifi-api//resources>"*... Any idea where the error
> is?
>
> Thank you,
>
>
>

Re: expression failure in URL concatenation?

Posted by l vic <lv...@gmail.com>.
Make sense. Thank you.

On Fri, Feb 1, 2019 at 10:09 AM Mark Payne <ma...@hotmail.com> wrote:

> No, if you wanted to evaluate the literal string you'd need to use
> ${literal("REST_URL")}
> When you use ${REST_URL:endsWith("...")} you are testing whether or not
> the value of the REST_URL
> variable ends with ...
> Think of it the same as just using the expression ${REST_URL} -- you
> expect that to return the value of the REST_URL
> variable, not the string literal "REST_URL". In your case, you're then
> just chaining together more EL calls.
>
> Thanks
> -Mark
>
>
> On Feb 1, 2019, at 9:30 AM, l vic <lv...@gmail.com> wrote:
>
>  "resolve the value of the REST_URL variable, then use that as the name of
> a variable."
> Doesn't seem to make much sense: the plan is to run "endsWith" on value of
> REST_URL, doesn't your expression set to tun it on literal string
> "REST_URL" within {...} ?
> Thank you,
>
> On Fri, Feb 1, 2019 at 8:58 AM Mark Payne <ma...@hotmail.com> wrote:
>
>> Hello,
>>
>> The issue appears to be that you're using `${${REST_URL}:endsWith`
>> at the beginning, which is saying "resolve the value of the REST_URL
>> variable, then use that as the name of a variable."
>> So it's looking for a variable named "http://localhost:8080/nifi-api"
>> and never finds it. So endsWith() evaluates to `false`
>> in all cases.
>>
>> What you want is instead:
>>
>> *${REST_URL:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}*
>>
>> I.e., check if the value of the REST_URL variable ends with a slash...
>>
>> Thanks
>> -Mark
>>
>>
>> On Jan 31, 2019, at 4:42 PM, l vic <lv...@gmail.com> wrote:
>>
>> I am using processor group variable as base part of my URL:
>> REST_URL=http://localhost:8080/nifi-api
>>
>> I am trying to append second part of URL in InvokeHTTP regardless if
>> REST_URL ends with '/', or not so that concatenation of "
>> http://localhost:8080/nifi-api/", or "http://localhost:8080/nifi-api"
>> with "resources" return the same URL: "
>> http://localhost:8080/nifi-api/resources":
>>
>> *${${REST_URL}:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}*
>>
>> But the expression always appends '/', so in the first case I end up with *
>> "http://localhost:8080/nifi-api//resources
>> <http://localhost:8080/nifi-api//resources>"*... Any idea where the
>> error is?
>> Thank you,
>>
>>
>>
>

Re: expression failure in URL concatenation?

Posted by Mark Payne <ma...@hotmail.com>.
No, if you wanted to evaluate the literal string you'd need to use ${literal("REST_URL")}
When you use ${REST_URL:endsWith("...")} you are testing whether or not the value of the REST_URL
variable ends with ...
Think of it the same as just using the expression ${REST_URL} -- you expect that to return the value of the REST_URL
variable, not the string literal "REST_URL". In your case, you're then just chaining together more EL calls.

Thanks
-Mark


On Feb 1, 2019, at 9:30 AM, l vic <lv...@gmail.com>> wrote:

 "resolve the value of the REST_URL variable, then use that as the name of a variable."
Doesn't seem to make much sense: the plan is to run "endsWith" on value of REST_URL, doesn't your expression set to tun it on literal string "REST_URL" within {...} ?
Thank you,

On Fri, Feb 1, 2019 at 8:58 AM Mark Payne <ma...@hotmail.com>> wrote:
Hello,

The issue appears to be that you're using `${${REST_URL}:endsWith`
at the beginning, which is saying "resolve the value of the REST_URL variable, then use that as the name of a variable."
So it's looking for a variable named "http://localhost:8080/nifi-api" and never finds it. So endsWith() evaluates to `false`
in all cases.

What you want is instead:
${REST_URL:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}

I.e., check if the value of the REST_URL variable ends with a slash...

Thanks
-Mark


On Jan 31, 2019, at 4:42 PM, l vic <lv...@gmail.com>> wrote:

I am using processor group variable as base part of my URL:
REST_URL=http://localhost:8080/nifi-api

I am trying to append second part of URL in InvokeHTTP regardless if REST_URL ends with '/', or not so that concatenation of "http://localhost:8080/nifi-api/", or "http://localhost:8080/nifi-api" with "resources" return the same URL: "http://localhost:8080/nifi-api/resources":
${${REST_URL}:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}

But the expression always appends '/', so in the first case I end up with "http://localhost:8080/nifi-api//resources"... Any idea where the error is?
Thank you,




Re: expression failure in URL concatenation?

Posted by l vic <lv...@gmail.com>.
 "resolve the value of the REST_URL variable, then use that as the name of
a variable."
Doesn't seem to make much sense: the plan is to run "endsWith" on value of
REST_URL, doesn't your expression set to tun it on literal string
"REST_URL" within {...} ?
Thank you,

On Fri, Feb 1, 2019 at 8:58 AM Mark Payne <ma...@hotmail.com> wrote:

> Hello,
>
> The issue appears to be that you're using `${${REST_URL}:endsWith`
> at the beginning, which is saying "resolve the value of the REST_URL
> variable, then use that as the name of a variable."
> So it's looking for a variable named "http://localhost:8080/nifi-api" and
> never finds it. So endsWith() evaluates to `false`
> in all cases.
>
> What you want is instead:
>
> *${REST_URL:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}*
>
> I.e., check if the value of the REST_URL variable ends with a slash...
>
> Thanks
> -Mark
>
>
> On Jan 31, 2019, at 4:42 PM, l vic <lv...@gmail.com> wrote:
>
> I am using processor group variable as base part of my URL:
> REST_URL=http://localhost:8080/nifi-api
>
> I am trying to append second part of URL in InvokeHTTP regardless if
> REST_URL ends with '/', or not so that concatenation of "
> http://localhost:8080/nifi-api/", or "http://localhost:8080/nifi-api"
> with "resources" return the same URL: "
> http://localhost:8080/nifi-api/resources":
>
> *${${REST_URL}:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}*
>
> But the expression always appends '/', so in the first case I end up with *
> "http://localhost:8080/nifi-api//resources
> <http://localhost:8080/nifi-api//resources>"*... Any idea where the error
> is?
> Thank you,
>
>
>

Re: expression failure in URL concatenation?

Posted by Mark Payne <ma...@hotmail.com>.
Hello,

The issue appears to be that you're using `${${REST_URL}:endsWith`
at the beginning, which is saying "resolve the value of the REST_URL variable, then use that as the name of a variable."
So it's looking for a variable named "http://localhost:8080/nifi-api" and never finds it. So endsWith() evaluates to `false`
in all cases.

What you want is instead:
${REST_URL:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}

I.e., check if the value of the REST_URL variable ends with a slash...

Thanks
-Mark


On Jan 31, 2019, at 4:42 PM, l vic <lv...@gmail.com>> wrote:

I am using processor group variable as base part of my URL:
REST_URL=http://localhost:8080/nifi-api

I am trying to append second part of URL in InvokeHTTP regardless if REST_URL ends with '/', or not so that concatenation of "http://localhost:8080/nifi-api/", or "http://localhost:8080/nifi-api" with "resources" return the same URL: "http://localhost:8080/nifi-api/resources":
${${REST_URL}:endsWith('/'):ifElse('${REST_URL}resources','${REST_URL}/resources')}

But the expression always appends '/', so in the first case I end up with "http://localhost:8080/nifi-api//resources"... Any idea where the error is?
Thank you,