So I have an auto rule that's sending a web request, the {{webResponse.body.data}} contains:
data={total=1, items=[{id=3186}]
I am trying to define variable {{DeviceID}} as '3186' however so far failing. Here's what I've tried the following smart values that are in an Add Comment task:
{{webResponse.body.data.items.split("=").substringBefore("}")}}
{{webResponse.body.data.items.split("=")}}
{{webResponse.body.data.items.split("=").last}}
{{webResponse.body.data.items.split("=").2}}{{webResponse.body.data.items.split("=").remove("{").remove("}")}}{{webResponse.body.data.items.split("=").remove("{}")}}
These are all attempts from what I can gleen through the various docs, and right now they all return null, nada, zilch.
{{webResponse.body.data.items}} returns {id=3186}
This looks like a shotgun approach but I was really trying to get less specific to find the cut off but it eludes me and at this point I'm lost.
Hi @Ben Hart ,
did you try using something like this :
{{webResponse.body.data.items.substringAfter("id=").substringBefore("}")}}
I guess this would work better, let me know if it doesn't.
--Alexis
So, no dice. The log step still showed nothing for this value. Now I gotta admit, I left off another two key=value pairs accidentally. the legit, and full value of data is:
data={total=1, items=[{id=3186}], searchId=null, isMin=false}
The full body is:
{status=200, errmsg=OK, data={total=1, items=[{id=3186}], searchId=null, isMin=false}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Experimenting further I've tried:
Log Action- second items : {{webResponse.body.data.items.substringAfter("items=[").substringBefore("}")}}
Which returns null. I did also try this without the `.substringBefore("}")}}` but it also flopped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is getting infuriating, so heres what I've got right now based on trying to further tweak `{id-1234}`:
1. log action: {{webResponse.body.data.items}}
this returns the value above {id=1234}
2. log action: {{webresponse.body.data.items.substringAfter("items=[{id=").substringBefore("}]")}}
logs nothing, empty.
3. log action: {{webResponse.body.data.items.match("(\b\d{3,4}\b)")}}
also nothing
4. log action: {{webResponse.body.data.substringAfter("items=[{id=").substringBefore("}]")}}
nothing as well.
Is there a better way to build these smart values? Like does this syntax adhere to Java, or some typical, normal language?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.