Expand my Community achievements bar.

SOLVED

Getting error while passing the content fragment path in the graphQL API end point

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 3

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-...

View solution in original post

5 Replies

Avatar

Community Advisor

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/ 



Arun Patidar

Avatar

Level 2

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 ?

Avatar

Community Advisor

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...

https://graphql.org/learn/queries/#variables

Avatar

Correct answer by
Level 3

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-...