Hi All,
I am using AEM6.5 SP13. I need to export content fragment headless content using graphql to external systems.
Every time I am running query on
http://localhost:4502/content/graphiql.html
Getting below error.
{
"errors": [
{
"message": "Failed to execute 'text' on 'Response': body stream already read",
"stack": "TypeError: Failed to execute 'text' on 'Response': body stream already read\n at http://localhost:4502/content/graphiql.html:81:33\n at async https://unpkg.com/graphiql/graphiql.min.js:29:224769"
}
]
}
Could anyone suggest what am I missing here?
In tools --> general I could not see graphql query editor option.
Any help is highly appreciated.
Thanks,
Pradeep
Views
Replies
Total Likes
Please check the below post which has the solution
You need to add the CSRF filter for the endpoints.
Hi @pradeepdubey82 ,
Please exclude the endpoints in Adobe Granite CSRF Filter configuration.
Thanks,
Milind
Excluded paths in CSRF, still same issue.
Can you please share the screen shot of the query you are trying and resultant error.
Also, have you also installed following essential packages :
Also, please follow step by step process below, this should resolve any installation issues:
Hello Krati,
CF preview
Query editor
I have installed graphiql-0.0.6.zip but not cfm-graphql-index-def-1.0.0.zip, is this needed to run the graphql query?
cfm-graphql-index-def.1.0.0.zip may not resolve the above issue, but it is an essential package from Query Performance perspective.
Coming back to the issue, this is essentially a CSRF issue, as pointed by others. Please check below link :
Also, validate that the Global Endpoint that you have defined is being correctly set in CSRF config.
If you think, all the values you have entered into CSRF config is correct, then please restart the bundle, or restart the local aem set up you are using:
Bundle:
Graphql is working fine once I added global endpoint in CSRF filter
/content/cq:graphql/global/endpoint
Not sure why this is needed as I have added all CF to custom site.
Glad that it worked.
Not sure why this is needed as I have added all CF to custom site.
@pradeepdubey82 Does the above mean, that you have defined a custom Endpoint instead of OOTB Global Endpoint? If that is so, custom Global Endpoint will work perfectly with External System, it is only the graphiQL interface that is bound to global endpoint especially for AEM On Prem. On AEMaaCS, we have the option to select EndPoints for GraphiQL interface. Look into below highlighted link
https://www.albinsblog.com/2021/10/how-to-deliver-headless-content-through-graphql-api-and-content-f....
AEMaaCS:
Yes I defined site specific endpoint instead of global. I think AEM6.5 works for global endpoint, and there is no provision to select endpoint while running the query in graphiql-0.0.6.zip(http://localhost:4502/content/graphiql.html). Also persist query doesn't support OOTB in AEM 6.5
So I would need to exclude global endpoint in CSRF filter instead of custom endpoint.
Next challenge is how these endpoint can be accessible by external systems? For now I am using basic authentication (user/password) with read/write permission to the user.
Is there any way like token authentication for accessing graphql query/endpoint by external system?
Appreciate your help Krati.
Thanks,
Pradeep
@pradeepdubey82 Please follow below blog for step by step process. This will answer all your queries:
Let me know, if you face any issue, in following these steps. It also explains how to query via external applications using curl command
Yes, since few days I am going through this article, in this article Albin has explained through basic authentication only, token based may be supporting in AEMAaCS not sure if it is there in AEM6.5
Using basic authentication and postman I am able to run all the requests GET,POST,PUT,DELETE on AEM6.5
-Best,
Pradeep
Hi @pradeepdubey82 and @krati_garg ,
I added entries in CSRF excluded path filter as below but still have same issue.
Error:
{
"errors": [
{
"message": "Failed to execute 'text' on 'Response': body stream already read",
"stack": "TypeError: Failed to execute 'text' on 'Response': body stream already read\n at http://localhost:4502/content/graphiql.html:81:33\n at async https://unpkg.com/graphiql/graphiql.min.js:29:224769"
}
]
}
Views
Likes
Replies
Views
Likes
Replies