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 { deleteIssue(id: \"issue_id\") { success } }",
"variables": {}
}
response = requests.delete(url, headers=headers, json=data)
if response.status_code >= 400:
print(response.text)
else:
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 { deleteIssue(id: \"issue_id\") { success } }",
"variables": {}
}
with httpx.Client() as client:
response = client.delete(url, headers=headers, json=data)
if response.status_code >= 400:
print(response.text)
else:
print(response.json())
import fetch from 'node-fetch';
import { env } from 'process';
const url = 'https://api.linear.app/graphql';
const headers = {
'Authorization': `Bearer ${env.LINEAR_API_KEY}`,
'Content-Type': 'application/json'
};
const data = {
query: 'mutation { deleteIssue(id: "issue_id") { success } }',
variables: {}
};
fetch(url, {
method: 'DELETE',
headers,
body: JSON.stringify(data)
})
.then(async response => {
if (response.status >= 400) {
console.log(await response.text());
} else {
console.log(await response.json());
}
})
.catch(err => console.error(err));
import axios from 'axios';
import { env } from 'process';
const url = 'https://api.linear.app/graphql';
const headers = {
'Authorization': `Bearer ${env.LINEAR_API_KEY}`,
'Content-Type': 'application/json'
};
const data = {
query: 'mutation { deleteIssue(id: "issue_id") { success } }',
variables: {}
};
axios.delete(url, { headers, data })
.then(response => {
if (response.status >= 400) {
console.log(response.data);
} else {
console.log(response.data);
}
})
.catch(err => console.error(err));
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
)
type requestBody struct {
Query string `json:"query"`
Variables map[string]interface{} `json:"variables"`
}
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 { deleteIssue(id: \"issue_id\") { success } }",
Variables: map[string]interface{}{},
}
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)
fmt.Println(string(body))
} else {
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
}
<?php
$url = 'https://api.linear.app/graphql';
$apiKey = getenv('LINEAR_API_KEY');
if (empty($apiKey)) {
die('LINEAR_API_KEY environment variable not set');
}
$headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
];
$data = [
'query' => 'mutation { deleteIssue(id: "issue_id") { success } }',
'variables' => []
];
$options = [
'http' => [
'method' => 'DELETE',
'header' => $headers,
'content' => json_encode($data),
'ignore_errors' => true
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
if ($http_response_header[0] >= 400) {
echo $response;
} else {
echo $response;
}
require 'net/http'
require 'json'
require 'uri'
url = URI.parse('https://api.linear.app/graphql')
api_key = ENV.fetch('LINEAR_API_KEY')
headers = {
'Authorization' => "Bearer #{api_key}",
'Content-Type' => 'application/json'
}
data = {
query: 'mutation { deleteIssue(id: "issue_id") { success } }',
variables: {}
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url.request_uri, headers)
request.body = data.to_json
response = http.request(request)
if response.code.to_i >= 400
puts response.body
else
puts response.body
end
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 { deleteIssue(id: \"issue_id\") { success } }",
"variables": [:]
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print(error)
return
}
guard let httpResponse = response as? HTTPURLResponse else {
print("Invalid response")
return
}
if httpResponse.statusCode >= 400 {
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print(responseBody)
}
} else {
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print(responseBody)
}
}
}
task.resume()
RunLoop.main.run()
use reqwest::blocking::Client;
use std::collections::HashMap;
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 mut headers = reqwest::header::HeaderMap::new();
headers.insert(
"Authorization",
format!("Bearer {}", api_key).parse()?,
);
headers.insert(
"Content-Type",
"application/json".parse()?,
);
let body: HashMap<&str, &str> = HashMap::from([
("query", "mutation { deleteIssue(id: \"issue_id\") { success } }"),
("variables", ""),
]);
let response = client
.delete(url)
.headers(headers)
.json(&body)
.send()?;
if response.status().is_client_error() || response.status().is_server_error() {
println!("{}", response.text()?);
} else {
println!("{}", response.text()?);
}
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;
}
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var body = new
{
query = "mutation { deleteIssue(id: \"issue_id\") { success } }",
variables = new { }
};
var response = await client.DeleteAsync(url, new StringContent(JsonSerializer.Serialize(body)));
if (!response.IsSuccessStatusCode)
{
var errorContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(errorContent);
}
else
{
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}