Log
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer YOUR_API_TOKEN");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.logsnag.com/v1/log", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var settings = {
"url": "https://api.logsnag.com/v1/log",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = JSON.stringify({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.logsnag.com/v1/log");
xhr.setRequestHeader("Authorization", "Bearer YOUR_API_TOKEN");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
var axios = require('axios');
var data = JSON.stringify({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
});
var config = {
method: 'post',
url: 'https://api.logsnag.com/v1/log',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': 'api.logsnag.com',
'path': '/v1/log',
'headers': {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = JSON.stringify({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
});
req.write(postData);
req.end();
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.logsnag.com/v1/log',
'headers': {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var unirest = require('unirest');
var req = unirest('POST', 'https://api.logsnag.com/v1/log')
.headers({
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
})
.send(JSON.stringify({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
}))
.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.raw_body);
});
import http.client
import json
conn = http.client.HTTPSConnection("api.logsnag.com")
payload = json.dumps({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": True
})
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
conn.request("POST", "/v1/log", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
import json
url = "https://api.logsnag.com/v1/log"
payload = json.dumps({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": True
})
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
require "uri"
require "json"
require "net/http"
url = URI("https://api.logsnag.com/v1/log")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer YOUR_API_TOKEN"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
})
response = https.request(request)
puts response.read_body
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.logsnag.com/v1/log"
method := "POST"
payload := strings.NewReader(`{
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.logsnag.com/v1/log',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_TOKEN',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.logsnag.com/v1/log');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Authorization' => 'Bearer YOUR_API_TOKEN',
'Content-Type' => 'application/json'
));
$request->setBody('{\n "project": "my-saas",\n "channel": "waitlist",\n "event": "Waitlist Member",\n "description": "email: [email protected]",\n "icon": "🔥",\n "notify": true\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://api.logsnag.com/v1/log');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
"project": "my-saas",
"channel": "waitlist",
"event": "Waitlist Member",
"description": "email: [email protected]",
"icon": "🔥",
"notify": true
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
'Authorization' => 'Bearer YOUR_API_TOKEN',
'Content-Type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Last modified 9mo ago