This article provides the resources to support the task of making REST-based calls with an API Key.
The following are examples of using the API key.
The caller passes the API key in the Authorization header like a bearer token.
POST /application HTTP/1.1
Content-Type: application/json
Authorization: Bearer YourApiKeyHere
Host: api.YourSubDomain.fuuz.app
Content-Length: 111
{"query":"query {\n\tcurrentUser {\n\t\tuser {\n\t\t\temail\n\t\t}\n\t\ttenant {\n\t\t\tname\n\t\t}\n\t}\n}\n"}
$headers=@{}
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Bearer YourApiKeyHere")
$response = Invoke-WebRequest -Uri 'https://api.YourSubDomain.fuuz.app/application' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"query":"query {\n\tcurrentUser {\n\t\tuser {\n\t\t\temail\n\t\t}\n\t\ttenant {\n\t\t\tname\n\t\t}\n\t}\n}\n"}'
Write $response
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer YourApiKeyHere")
$headers.Add("Content-Type", "application/json")
$body = @"
{`"query`":`"query {`\n`\tcurrentUser {`\n`\t`\tuser {`\n`\t`\t`\temail`\n`\t`\t}`\n`\t`\ttenant {`\n`\t`\t`\tname`\n`\t`\t}`\n`\t}`\n}`\n`"}
"@
$response = Invoke-RestMethod 'https://api.YourSubDomain.fuuz.app/application' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
When using a Windows command terminal, it may be necessary to escape the double quotes and avoid single quotes, as is done in this example, which includes Windows-style command continuation with carets.
curl.exe https://api.YourSubDomain.fuuz.app/application ^
-H "Authorization: Bearer YourApiKeyHere" ^
-H "Content-Type: application/json" -d "{\"query\":\"query{ currentUser { user { email } }}\"}" -v
{
"data": {
"currentUser": {
"user": {
"email": "no-reply@domain.com
},
"tenant": {
"name": "Tenant Name
}
}
}
}