sendHttpGetRequest

Hi Community,

When sending this URL
https://datalake-prod2018.rbfa.be/graphql?operationName=GetTeamCalendar&variables={"teamId":"218610","language":"nl","sortByDate":"asc"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"bf4be0c185dee11a27079e529a04d41dc692389ada678dac1f2280e056de7b7d"}}
with a sendHttpGetRequest i get the error
failed: Illegal character in query at index 82:

even after replacing the { with %7B and the } with %7D…
the same error…

someone another suggestion?

many thanks

Wouldn’t character 82 be " ?
You probably ought to show us where you are defining your string.
var fred = " { "apple" : 2} "
isn’t going to work

Hi @rossko57 ,

Have done it this way:

// Global variables/constants
val String filename = "Voetbal.rules"


val java.util.concurrent.locks.ReentrantLock apiLock = new java.util.concurrent.locks.ReentrantLock
val String v1 = "{\"teamId\":\"218610\",\"language\":\"nl\",\"sortByDate\":\"asc\"}"
val String v2 = "{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"bf4be0c185dee11a27079e529a04d41dc692389ada678dac1f2280e056de7b7d\"}}"

// Get VoetbalKalender
rule "Voetbal: getVoetbalKalender"
when
    Item vgetAccessToken changed to ON
then
    try
    {
        apiLock.lock()

        var String url = "https://datalake-prod2018.rbfa.be/graphql?operationName=GetTeamCalendar&variables=" + v1 + "&extensions=" + v2 
        //val headers = newHashMap()

        var String jsonData = sendHttpGetRequest(url)
        if (jsonData.isNullOrEmpty)
        {
            logError(filename, "Cannot update the authorization tokens. JSON-data is empty.")
            return;
        }    
    
        logInfo(filename, "getVoetbalKalender, Ontvangen jsondata: " + jsonData)

    }
    finally
    {
        apiLock.unlock()
    }
end

When executing i receive the error:

failed: Illegal character in query at index 82: https://datalake-prod2018.rbfa.be/graphql?operationName=GetTeamCalendar&variables={"teamId":"218610","language":"nl","sortByDate":"asc"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"bf4be0c185dee11a27079e529a04d41dc692389ada678dac1f2280e056de7b7d"}}

Oh, index 82 is the curly braces I think - these are ‘unsafe characters’ in URLs and should be encoded.