import os
import requests
url = "https://api.linear.app/graphql"
headers = {
"Authorization": f"Bearer {os.environ['LINEAR_API_TOKEN']}",
"Content-Type": "application/json"
}
data = {
"query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { 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_TOKEN']}",
"Content-Type": "application/json"
}
data = {
"query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { 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';
import { config } from 'dotenv';
config();
const url = 'https://api.linear.app/graphql';
const headers = {
'Authorization': `Bearer ${process.env.LINEAR_API_TOKEN}`,
'Content-Type': 'application/json'
};
const data = {
query: 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { 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';
import { config } from 'dotenv';
config();
const url = 'https://api.linear.app/graphql';
const headers = {
'Authorization': `Bearer ${process.env.LINEAR_API_TOKEN}`,
'Content-Type': 'application/json'
};
const data = {
query: 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { 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 GraphQLRequest struct {
Query string `json:"query"`
}
func main() {
url := "https://api.linear.app/graphql"
token := os.Getenv("LINEAR_API_TOKEN")
if token == "" {
log.Fatal("LINEAR_API_TOKEN environment variable not set")
}
reqBody := GraphQLRequest{
Query: "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }",
}
body, _ := json.Marshal(reqBody)
req, err := http.NewRequest("DELETE", url, bytes.NewBuffer(body))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
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, string(body))
}
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
<?php
$url = 'https://api.linear.app/graphql';
$token = getenv('LINEAR_API_TOKEN');
if (empty($token)) {
die('LINEAR_API_TOKEN environment variable not set');
}
$data = [
'query' => 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { success } }'
];
$options = [
'http' => [
'method' => 'DELETE',
'header' => [
'Authorization: Bearer ' . $token,
'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')
token = ENV.fetch('LINEAR_API_TOKEN') { raise 'LINEAR_API_TOKEN environment variable not set' }
request = Net::HTTP::Delete.new(url)
request['Authorization'] = "Bearer #{token}"
request['Content-Type'] = 'application/json'
request.body = {
query: 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { success } }'
}.to_json
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
response = http.request(request)
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP error! status: #{response.code}, body: #{response.body}"
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_TOKEN"] ?? "")", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: Any] = [
"query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { 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 std::env;
use reqwest::blocking::Client;
use serde_json::json;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = "https://api.linear.app/graphql";
let token = env::var("LINEAR_API_TOKEN")?;
let client = Client::new();
let response = client
.delete(url)
.header("Authorization", format!("Bearer {}", token))
.header("Content-Type", "application/json")
.json(&json!({
"query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }"
}))
.send()?;
if !response.status().is_success() {
return Err(format!("HTTP error! status: {}", response.status()).into());
}
let body = response.json::<serde_json::Value>()?;
println!("{:?}", body);
Ok(())
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text.Json;
class Program
{
static async Task Main()
{
var url = "https://api.linear.app/graphql";
var token = Environment.GetEnvironmentVariable("LINEAR_API_TOKEN");
if (string.IsNullOrEmpty(token))
{
throw new Exception("LINEAR_API_TOKEN environment variable not set");
}
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var body = new { query = "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }" };
var content = new StringContent(JsonSerializer.Serialize(body), System.Text.Encoding.UTF8, "application/json");
var response = await client.DeleteAsync(url, content);
if (!response.IsSuccessStatusCode)
{
throw new Exception($"HTTP error! status: {response.StatusCode}");
}
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}