I have written graphQL Query to get the country data by path
Query :
query getCountryData($path:ID!){
countryList(
filter:{
_path:{
_expressions:[{
value:$path
_operator:STARTS_WITH
}]
}
}
){
items{
countryName
countryCode
countryIsdCode
}
}
}
Request :
{"path": "/content/dam/test/cf/country/en_UK/"}
API end point :
http://localhost:4502/graphql/execute.json/sia/country;path=/content/dam/test/cf/country/en_UK/;
When I hit this end point I'm getting error like the below
{"errors":[{"errorType":"ServletError","message":"Internal Servlet Failure","details":"Suffix: '/test/country/content/dam/test/cf/country/en_UK/' does not contain a path"}]}
Do we have any solution for this
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Vignesh_K_S
Can you try to encode the path /content/dam/test/cf/country/en_UK? And add this as parameter value in your request. You can use this site to do it manually: https://www.urlencoder.org
That should make it work. I am assuming you'll use it in an application. If you do that they are functions that already exist that encode your values to pass it in your url. In JavaScript you can use the function encodeURIComponent, like mentioned in this topic: https://stackoverflow.com/questions/28915717/how-does-one-safely-pass-a-url-and-filename-as-part-of-...
Hi @Vignesh_K_S
The path does not look correct
/test/country/content/dam/test/content-fragment/country/en_UK/
It should be like /content/dam/test/content-fragment/country/en_UK/
Yes, But in the request I'm passing the correct content fragment asset path
/content/dam/test/cf/country/en_UK/. Internally it is trying to access the wrong path
/test/country/content/dam/test/cf/country/en_UK/
Can you please suggest how we can pass the asset path in graphQL API ?
Hi @Vignesh_K_S
You check the sling resource resolution rule?
https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html
Hi @Vignesh_K_S ,
In your query, it mentioned that the $path type as ID, try to change it to String and check as you are passing the string as a value.
For more information refer https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/graphql...
Hi Vignesh_K_S
Can you try to encode the path /content/dam/test/cf/country/en_UK? And add this as parameter value in your request. You can use this site to do it manually: https://www.urlencoder.org
That should make it work. I am assuming you'll use it in an application. If you do that they are functions that already exist that encode your values to pass it in your url. In JavaScript you can use the function encodeURIComponent, like mentioned in this topic: https://stackoverflow.com/questions/28915717/how-does-one-safely-pass-a-url-and-filename-as-part-of-...
Views
Likes
Replies
Views
Likes
Replies