Script to call an API and check for an object
The aim of this script to call an API end point that provides multiple parameters. One of the parameters is a feature mapping that has two parts. What I want to do is check if that feature is mapped in the list if not, add it.
I have tried multiple ways, but can’t seem to find a logic that adds the items at the end.
attempt one: alter the string the self.
I first tried using the json string that is recieved by the API call for indexOf(jsonString; {"id1":"value1","id2":"value2"})
but that didn’t work. And value1 and value2 can be found partially in the json string, so I cant even use two conditions where one is indexOf(jsonString;id1:value1)
does not equal -1 for both ids.
attempt two: checking the array using iterator and adding the item to the list.
So I converting the jsonString to json and using Iterator to filter for the two conditions id1 equals to value1 and id2 equals value2.
However, when I try to add the item to the json object and convert it to a json string and send it but the formatting is incorrect. I checked by using slack and the jsonstring object I added is "{\"id1\":\"value1\",\"id2\":\"value2\"}"
while all other items in jsonstring is {"id1":"value1,"id2":value2"}
I don’t know what I am doing wrong, but I feel like I am starting to overcomplicate the sequence. Any help would be great. Thanks