Getting started with Ruby
Alerts API querying example with Ruby
Request code
require 'net/http'
require 'json'
API_KEY = "<REPLACE_WITH_YOUR_KEY>"
API_ENDPOINT = "https://api.craft.co/v1/query"
GRAPHQL_QUERY = "query getAlerts($first: Int!) { alerts(first: $first) { id dataset variable } }"
request_headers= { "Content-Type": "application/json", "x-craft-api-key": API_KEY }
request_data = {
"query": GRAPHQL_QUERY,
"variables": { "first": 3 }
}
response = Net::HTTP.post(URI(API_ENDPOINT), request_data.to_json, request_headers)
puts response.bodyResponse
Read more
Last updated
Was this helpful?