import os
import requests
url = "https://api.linear.app/graphql"
headers = {
"Authorization": f"Bearer {os.environ['LINEAR_API_KEY']}",
"Content-Type": "application/json"
}
data = {
"query": "mutation { issueDelete(input: { id: \"issue123\" }) { success } }"
}
response = requests.delete(url, headers=headers, json=data)
response.raise_for_status()
print(response.json())
import os
import httpx
url = "https://api.linear.app/graphql"
headers = {
"Authorization": f"Bearer {os.environ['LINEAR_API_KEY']}",
"Content-Type": "application/json"
}
data = {
"query": "mutation { issueDelete(input: { id: \"issue123\" }) { success } }"
}
with httpx.Client() as client:
response = client.delete(url, headers=headers, json=data)
response.raise_for_status()
print(response.json())
import fetch from 'node-fetch';
const url = 'https://api.linear.app/graphql';
const headers = {
'Authorization': `Bearer ${process.env.LINEAR_API_KEY}`,
'Content-Type': 'application/json'
};
const data = {
query: 'mutation { issueDelete(input: { id: "issue123" }) { success } }'
};
fetch(url, {
method: 'DELETE',
headers,
body: JSON.stringify(data)
})
.then(res => {
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
return res.json();
})
.then(console.log)
.catch(console.error);
import axios from 'axios';
const url = 'https://api.linear.app/graphql';
const headers = {
'Authorization': `Bearer ${process.env.LINEAR_API_KEY}`,
'Content-Type': 'application/json'
};
const data = {
query: 'mutation { issueDelete(input: { id: "issue123" }) { success } }'
};
axios.delete(url, { headers, data })
.then(res => {
if (res.status >= 400) throw new Error(`HTTP error! status: ${res.status}`);
console.log(res.data);
})
.catch(console.error);
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
)
type requestBody struct {
Query string `json:"query"`
}
func main() {
url := "https://api.linear.app/graphql"
apiKey := os.Getenv("LINEAR_API_KEY")
if apiKey == "" {
log.Fatal("LINEAR_API_KEY environment variable not set")
}
body := requestBody{
Query: "mutation { issueDelete(input: { id: \"issue123\" }) { success } }",
}
jsonBody, err := json.Marshal(body)
if err != nil {
log.Fatal(err)
}
req, err := http.NewRequest("DELETE", url, bytes.NewBuffer(jsonBody))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
body, _ := io.ReadAll(resp.Body)
log.Fatalf("HTTP error! status: %d, body: %s", resp.StatusCode, body)
}
var result map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
log.Fatal(err)
}
fmt.Println(result)
}
<?php
$url = 'https://api.linear.app/graphql';
$apiKey = getenv('LINEAR_API_KEY');
if (empty($apiKey)) {
die('LINEAR_API_KEY environment variable not set');
}
$data = [
'query' => 'mutation { issueDelete(input: { id: "issue123" }) { success } }'
];
$options = [
'http' => [
'method' => 'DELETE',
'header' => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
],
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === false) {
die('Request failed');
}
$response = json_decode($result, true);
print_r($response);
require 'net/http'
require 'json'
require 'uri'
url = URI.parse('https://api.linear.app/graphql')
api_key = ENV.fetch('LINEAR_API_KEY')
body = {
query: 'mutation { issueDelete(input: { id: "issue123" }) { success } }'
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url.path, {
'Authorization' => "Bearer #{api_key}",
'Content-Type' => 'application/json'
})
request.body = body.to_json
response = http.request(request)
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP error! status: #{response.code}"
end
puts JSON.parse(response.body)
import Foundation
let url = URL(string: "https://api.linear.app/graphql")!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
request.setValue("Bearer \(ProcessInfo.processInfo.environment["LINEAR_API_KEY"] ?? "")", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: Any] = [
"query": "mutation { issueDelete(input: { id: \"issue123\" }) { success } }"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else {
print("HTTP error! status: \((response as? HTTPURLResponse)?.statusCode ?? 0)")
return
}
if let data = data, let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
print(json)
}
}
task.resume()
RunLoop.main.run()
use reqwest::blocking::Client;
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = "https://api.linear.app/graphql";
let api_key = env::var("LINEAR_API_KEY")?;
let client = Client::new();
let body = serde_json::json!({
"query": "mutation { issueDelete(input: { id: \"issue123\" }) { success } }"
});
let response = client
.delete(url)
.header("Authorization", format!("Bearer {}", api_key))
.header("Content-Type", "application/json")
.json(&body)
.send()?;
if !response.status().is_success() {
return Err(format!("HTTP error! status: {}", response.status()).into());
}
let json: serde_json::Value = response.json()?;
println!("{:?}", json);
Ok(())
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var url = "https://api.linear.app/graphql";
var apiKey = Environment.GetEnvironmentVariable("LINEAR_API_KEY");
if (string.IsNullOrEmpty(apiKey))
{
Console.WriteLine("LINEAR_API_KEY environment variable not set");
return;
}
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Delete, url);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent(
JsonSerializer.Serialize(new { query = "mutation { issueDelete(input: { id: \"issue123\" }) { success } }" }),
System.Text.Encoding.UTF8,
"application/json"
);
var response = await client.SendAsync(request);
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"HTTP error! status: {response.StatusCode}");
return;
}
var json = await response.Content.ReadAsStringAsync();
Console.WriteLine(json);
}
}