Mutations need to be sent as separate requests. This is a graphQL usage design and not an API specific setting.
In other words, if I want to generate and enable persistent url, I need to use the first query to get the http service Id, then pass it to the mutation on the second query subsequently?
First Query
{
"query": "{
login {
account(id: \"${accountId}\") {
devices(name: \"${deviceName}\"){
items{ id name services(name: \"http\") { id name } enabled state }
}
}
}
}"
}
You can do one query to fetch all of your devices without filtering to get a specific device name and iterate over the results instead of a request for each device. In your iteration, you can then make the mutation call to make a change if one is needed.
Via curl, I thunk it is authorizing correctly now (I get a json-formatted list of devices & services returned!).
Now, the query issued, as seen above, isnât working (yet); the output i get:
$ ./qry1
GRAPHQL_URL=https://api.remote.it/graphql/v1
DATA_QRY1={
query: "{
login {
account(id: "<email-id-i-registered>") {
devices(name: "kenix-raspberrypi4-<...>"){
items{ id name services(name: "http") { id name } enabled state }
}
}
}
}"
}
{"message":"Forbidden"}
(The value of the variables in the script i use are shown). Is something wrong with the query syntax? Is the âidâ field right?
Given a service on a device (say, http_80), how can I programatically - via curl, ideally - start it / âconnectâ it, and once connected, fetch itâs endpoint (proxy url:port#)?
If your authentication is working, the next step is to ensure you have the correct query. I usually use Insomnia to test and perfect all my queries before porting them to code.
You donât need to specify the account explicitly since itâs inferred from your credentials. The query you want is:
query {
login {
account {
devices( name:"home") {
items{ id name }
}
}
}
}
This is a valid query. Using Insomnia with the remote.it plugin is highly recommended as it generates all your queries without errors by leveraging the schema and validating whatâs allowed. Alternatively, you can use the network debug feature in Firefox or Chrome to inspect the queries made in the web portal.
#Proxy connections can be generated to individual services and the unique
#address will be provided in the host and port fields.
#
#hostIP values could contain
#
#0.0.0.0 for fully public connections available to user
#
#255.255.255.255 to allow only the first accessing IP to "Latch" the connection.
#Blocking all others
#
#A unique public IP address to only allow that IP to access the connection
mutation GetConnection($serviceId: String!, $hostIP: String!) {
connect(serviceId: $serviceId, hostIP: $hostIP) {
id
created
host
port
reverseProxy
timeout
}
}