Passing Params to Persisted Query Endpoint AEM GQL | Community
Skip to main content
Level 4
September 29, 2022
Solved

Passing Params to Persisted Query Endpoint AEM GQL

  • September 29, 2022
  • 2 replies
  • 5066 views

I know that we can use POST method to make normal GQL query and perform GQL Ops but I wanted to know how can we achieve the same for persisted query, when I make a POST call with variables, I get an error:

 



When I copy URL which takes variables AEM gives URL which looks like this:

https://<DOMAIN>/graphql/execute.json/GetArticlesByID;filterExpressions=

 

and here's how my variable looks like:

 

{ "filterExpressions": {"_logOp":"OR","_expressions":[{"value":"422322","_operator":"EQUALS"},{"value":"422321","_operator":"EQUALS"}]} }

 

 

when I pass it directly in filterExpressions, it gives me error saying:

"Variable 'filterExpressions' has an invalid value : Expected type 'Map' but was 'String'. Variables for input objects must be an instance of type 'Map'."
 
I am not sure why endpoint is designed the the way it is? Is it possible to pass in params in get call as query params or does it have to be in some other way?
Best answer by spidey1405

I needed to encode my parameters using URIEncode after which it worked fine.

2 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
September 29, 2022

You can pass the parameters like this

 

Query variables can be used with Persisted Queries. The query variables are appended to the request prefixed with a semicolon (;) using the variable name and value. Multiple variables are separated by semicolons.

The pattern looks like the following:

<AEM_HOST>/graphql/execute.json/<PERSISTENT_QUERY_PATH>;variable1=value1;variable2=value2
 

 Check the example given here

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/persisted-queries.html?lang=en 

April 11, 2025

It works for me 

Thanks!

spidey1405AuthorAccepted solution
Level 4
September 30, 2022

I needed to encode my parameters using URIEncode after which it worked fine.

November 7, 2022

Could you please provide the complete url (non-encoded and encoded)? Even after encoding, I still get the error.

Nikita_Mitroshin
Level 2
January 16, 2023

Hey @spidey1405 @rakesh.h021 

I'm having exactly the same issue, would be great if you can share more details if you resolved it.

Thanks