GraphQL for Delphi make http request

Apologies for posting here I cannot post in the DEV group.

Delphi 11.2
I am struggling to connect to FreePBX GraphQL with the following code




Syntax attempts for myQuery (all failed)

      myQuery := '{"query": "{fetchInstalledModules {id }}"}';
      myQuery := 'query:\fetchInstalledModules {id }';
      myQuery := '{"query":"query{fetchInstalledModules{id}}","variables":{}}';
      myQuery := '"query":"query{fetchInstalledModules{id}","variables":{}';

      params.Add(myQuery)   ;
      memo1.Text := params.DelimitedText;
      NetHTTPClient1.CustomHeaders['Content-Type'] := 'application/json';
      NetHTTPClient1.CustomHeaders['Authorization'] := 'Bearer '+token;
      memoLog.Lines.Text := NetHTTPClient1.Post('http://myDomain.com:83/admin/api/api/gql', params).ContentAsString;

{"errors":[{"message":"GraphQL Request must include at least one of those two parameters: \"query\" or \"queryId\"","status":false}]}

I have installed GraphQL for Delphi but the demo just shows loading from file. Can I call this from GraphQL for Delphi. If so what is the code please.

PS I am able to use query:\fetchInstalledModules {id } in Postman and get data returned so I know my token is working.

GraphQL for Delphi is intended to be used to create GraphQL servers, not clients. Doing requests to arbitrary GraphQL servers from clients should be rather simple.

You could refer to GraphQL documentation itself:

None of your questions look correct, probably you should use something like this:

{ fetchInstalledModules(id: 120) { field1, field2 } }

I'm just guessing field1 and field2. But you should really check the documentation of the GraphQL server you are trying to access.

Thanks for the info insight.

I have the query working in Postman and returning data.

Cheers