First API Call
7 min
your first api call a 60 second sanity check get a token, hit one endpoint, see a 200 run this call live every example on this page also lives in the litmus api collection https //api litmus io/view/2s9y5r1rvg open the collection, fork it, paste your token, and hit send 1\ get a token token=$(curl sk x post "https //\<edge host>/auth/v3/oauth/token" \\ h "content type application/x www form urlencoded" \\ d "grant type=client credentials" \\ d "client id=$client id" \\ d "client secret=$client secret" | jq r access token) k skips tls verification use only against self signed dev instances see ssl certificates # before doing this in production 2\ call a read only endpoint curl sk "https //\<edge host>/devicehub/version" \\ h "authorization bearer $token" expected a json object with a version field if you see this, auth and routing work 3\ try a graphql call devicehub is graphql list drivers on the edge curl sk x post "https //\<edge host>/devicehub/v2" \\ h "authorization bearer $token" \\ h "content type application/json" \\ d '{"query" "query { listdrivergroups { id name drivers { id name } } }"}' graphql endpoints return http 200 even on errors check the errors key in the response body, not just the status code see graphql vs rest # python equivalent import os, requests edge = os environ\["edge url"] r = requests post( f"{edge}/auth/v3/oauth/token", data={ "grant type" "client credentials", "client id" os environ\["client id"], "client secret" os environ\["client secret"], }, verify=false, ) token = r json()\["access token"] v = requests get(f"{edge}/devicehub/version", headers={"authorization" f"bearer {token}"}, verify=false) print(v json()) troubleshooting symptom likely cause 401 unauthorized token expired, wrong client id/secret, or wrong header (lem uses x authtoken , not bearer ) 404 not found wrong base url or path prefix see base urls # ssl certificate verify failed self signed cert see ssl certificates # graphql returns 200 but no data check errors key in the body, not just http status