Totara Learn Open Discussions

Use GraphQL from external application

 
Gabriela Sanchez
Use GraphQL from external application
by Gabriela Sanchez - Thursday, 11 March 2021, 8:32 AM
 
Hello! I have been testing the GraphQL services and so far it is ok while I'm logged in in the browser (I am using Altair to test it). However, I actually need it from an external appplication, for example Postman. So far, every request I make returns an error that requires login. I have tried basic authentication with username and password, bearer token using the same as the web services. The TotaraSession cookie is generated but no response is received.  


Appreciate if you could help me with this.

I searched this topic in the forums but did not find anything related to it.


Craig Eves
Re: Use GraphQL from external application
by Craig Eves (Totara Support) - Tuesday, 16 March 2021, 7:40 PM
Group Totara

Hi Gabriela

There is some documentation on using  GraphQL in Totara here that should be helpful. 

This part may be relevant but don't know if your query is a persisted query

  1. AJAX endpoint ([siteurl]/totara/webapi/ajax.php): Endpoint used by the application javascript to access and modify data. Supports both unauthenticated and authenticated access. For authenticated access, authentication is via the normal web session cookie with a 'sesskey' token used to prevent cross-site request forgery (CSRF). The AJAX endpoint only supports persisted queries and mutations (queries defined in files in code not arbitrary queries provided as part of the request*).
Regards