String Replace Issue

Moderators: anncoupe, anncoupe

Post Reply
rhd_ole
Member
Posts: 36
Joined: Mon Jan 24, 2022 5:36 pm

String Replace Issue

Post by rhd_ole »

Hello Switch World -

To keep this simple, I'm trying to make a URL that is web safe. So I need to remove the spaces and replace them with %20.

The URL is built from various privatedata values and some static info.. Only one privatedata value will ever contain spaces, "description" this is the string I need to change

After searching the forums, String Replace seemed to be the easy solution, however I don't get any results even when trying to replace a word such as "START" with "DONE"

My process and how String Replace is setup:
I'm looking to change the value in privatedata key "description". ( in my test the value is START this test )
Mode: Privat Data
Data: [Job.PrivateData:Key="description"
Separator: =
Strings: START=DONE
Global: Yes
Ignore case: Yes
Screenshot 2023-01-02 at 11.27.00 AM.png
Screenshot 2023-01-02 at 11.27.00 AM.png (52.49 KiB) Viewed 5480 times

The result is the same "START this test" vs what it should be "DONE this test" as the new privatedata.

Am I missing something or is there another way?
jan_suhr
Advanced member
Posts: 556
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: String Replace Issue

Post by jan_suhr »

In the Property "Data" you should have the name of the Private Data key.

In other words it should just say "description"

Then if there is a value "START" in that Private data value you will get the result "DONE", otherwise nothing will happen.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
rhd_ole
Member
Posts: 36
Joined: Mon Jan 24, 2022 5:36 pm

Re: String Replace Issue

Post by rhd_ole »

jan_suhr wrote: Mon Jan 02, 2023 7:39 pm In the Property "Data" you should have the name of the Private Data key.

In other words it should just say "description"

Then if there is a value "START" in that Private data value you will get the result "DONE", otherwise nothing will happen.
I feel dumb now, but thank you very much. Of all the things I tried, this didn't cross my mind but makes total sense now that you pointed it out.

Works perfectly!!

Thanks again.
freddyp
Advanced member
Posts: 924
Joined: Thu Feb 09, 2012 3:53 pm

Re: String Replace Issue

Post by freddyp »

Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202

or with:

URL: https://mysite.com
Parameters: param 1=value 1
param 2=value 2
rhd_ole
Member
Posts: 36
Joined: Mon Jan 24, 2022 5:36 pm

Re: String Replace Issue

Post by rhd_ole »

freddyp wrote: Tue Jan 03, 2023 8:59 am Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202

or with:

URL: https://mysite.com
Parameters: param 1=value 1
param 2=value 2
Thank you the suggestion I will look into that.

A bit of background what I'm doing here. I do have it working. The URL is built to pass into an email body for art upload but also posting the link via API to our project management site, this is similar to Monday.com, Smartsheets, etc. It was the last missing part.
Mirandajoye
Newbie
Posts: 2
Joined: Fri May 05, 2023 4:12 am

Re: String Replace Issue

Post by Mirandajoye »

freddyp wrote: Tue Jan 03, 2023 8:59 am Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202 uno online

or with:

URL: https://mysite.com
Parameters: param 1=value 1
param 2=value 2
Can you be more specific about creating such a URL?
frailwhen
Newbie
Posts: 5
Joined: Tue Dec 13, 2022 5:21 am

Re: String Replace Issue

Post by frailwhen »

Mirandajoye wrote: Mon Jun 26, 2023 5:31 am
freddyp wrote: Tue Jan 03, 2023 8:59 am Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202 slope game

or with:

URL: https://mysite.com
Parameters: param 1=value 1
param 2=value 2
Can you be more specific about creating such a URL?
The URL is formatted to be passed into the body of an email for the purpose of uploading artwork, and submitting the link through API to our project management website is also supported.
lilycollins
Newbie
Posts: 3
Joined: Wed Jan 04, 2023 8:53 am

Re: String Replace Issue

Post by lilycollins »

rhd_ole wrote: Tue Jan 03, 2023 12:34 pm
freddyp wrote: Tue Jan 03, 2023 8:59 am Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202

or with:

URL: https://mysite.com Geometry Dash
Parameters: param 1=value 1
param 2=value 2
Thank you the suggestion I will look into that.

A bit of background what I'm doing here. I do have it working. The URL is built to pass into an email body for art upload but also posting the link via API to our project management site, this is similar to Monday.com, Smartsheets, etc. It was the last missing part.
In the context of an "HTTP request" element, the URL property takes the provided value as is. This means that any special characters, including spaces, should be properly URL-encoded in the URL property.
Mirandajoye
Newbie
Posts: 2
Joined: Fri May 05, 2023 4:12 am

Re: String Replace Issue

Post by Mirandajoye »

frailwhen wrote: Mon Jul 17, 2023 5:17 am
Mirandajoye wrote: Mon Jun 26, 2023 5:31 am
freddyp wrote: Tue Jan 03, 2023 8:59 am Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202 connections

or with:

URL: https://mysite.com
Parameters: param 1=value 1
param 2=value 2
Can you be more specific about creating such a URL?
The URL is formatted to be passed into the body of an email for the purpose of uploading artwork, and submitting the link through API to our project management website is also supported.
That's it, I have a better understanding of this issue, thank you very much
earlgordon
Newbie
Posts: 2
Joined: Tue Sep 05, 2023 6:29 am

Re: String Replace Issue

Post by earlgordon »

Check that the Set Private Data component is placed after the step where the value gets changed, not before.dino game
annajenny
Newbie
Posts: 1
Joined: Thu Sep 14, 2023 8:54 am

Re: String Replace Issue

Post by annajenny »

It seems like you're facing an issue with the String Replace function. To address this problem, consider the following solution:
Check the Data Format: Ensure that the format of your data in the "description" privatedata key matches exactly with "START" (e.gword finder, no extra spaces or characters). Verify the Separator: Confirm that the separator used in your data is indeed an equal sign (=).
mayomayo72218
Newbie
Posts: 1
Joined: Fri Jun 30, 2023 10:57 am

Re: String Replace Issue

Post by mayomayo72218 »

annajenny wrote: Mon Sep 18, 2023 9:02 am It seems like you're facing an issue with the String Replace function. To address this problem, consider the following solution:
Check the Data Format: Ensure that the format of your data in the "description" privatedata key matches exactly with "START" (e.gword finder, no extra spaces or characters). Verify the Separator: Confirm that the separator used in your data is indeed an equal sign (=).
That's a great solution, I really like it. thank you for sharing!
Vampire Survivors
huntshaded
Newbie
Posts: 3
Joined: Mon Jul 17, 2023 4:13 am

Re: String Replace Issue

Post by huntshaded »

Make sure the Set Private Data step comes after the one in which the value is modified gorilla tag
Post Reply