toolfolks
(Stephen Warburton)
1
I am using Delphi 11.2 using TNetHttpClient component
I have manage to connect get my token okay.
I can get the GraphQL query returned in Postman ok.
I am now trying to get a simple query to run as follows:
Params.Add('query:\' + 'fetchInstalledModules {id }}"');
NetHTTPClient1.CustomHeaders['Content-Type'] := 'application/json';
NetHTTPClient1.CustomHeaders['Authorization'] := 'Bearer '+token;
memoLog.Lines.Text := NetHTTPClient1.Post('http://pbx.safeguardmeathome.com:83/admin/api/api/gql', params).ContentAsString;
I have tried various ‘guesses’ on this line
Params.Add('query:\' + 'fetchInstalledModules {id }}"');//,"variables":{);
I get this returned.
{"errors":[{"message":"GraphQL Request must include at least one of those two parameters: \"query\" or \"queryId\"","status":false}]}
Anyone know how I format the parameter.
toolfolks
(Stephen Warburton)
3
Thanks for the reply but I know the query I need eg
query : {fetchInstalledModules {id }}
My issue is whatever syntax I use I get
{"errors":[{"message":"GraphQL Request must include at least one of those two parameters: \"query\" or \"queryId\"","status":false}]}
So I need the correct syntax here
Params.Add('query:\' + 'fetchInstalledModules {id }}"');//,"variables":{);
Cheers
comtech
(Com Tech)
4
Framework Module GraphQL APIs - PBX GUI - Documentation (freepbx.org)
fetchinstalledmodules is expecting.
query {
fetchInstalledModules {
status
message
modules{
name,
state,
version,
license
}
}
}
toolfolks
(Stephen Warburton)
5
If I send this in postman
{fetchInstalledModules {id }}
I get
{
"data": {
"fetchInstalledModules": {
"id": "bW9kdWxlOg=="
}
}
}
I am just trying to use the simplest query to get a Jason reply from GraphQL
toolfolks
(Stephen Warburton)
6
Delphi 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;
toolfolks
(Stephen Warburton)
7
I have manage to create a new extension in Postman. So there is an error in the way I am adding the query in Delphi.
Any ideas?