Created
December 2, 2022 10:35
-
-
Save paulwababu/753a9c405df95af9d684cb3b352a8196 to your computer and use it in GitHub Desktop.
Testing PESAPEDIA API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new RestClient("https://pesapedia.co.ke/api/v2/hello"); | |
client.Timeout = -1; | |
var request = new RestRequest(Method.GET); | |
request.AddHeader("Authorization", "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e"); | |
request.AlwaysMultipartFormData = true; | |
IRestResponse response = client.Execute(request); | |
Console.WriteLine(response.Content); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --location --request GET 'https://pesapedia.co.ke/api/v2/hello' \ | |
--header 'Authorization: Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var headers = { | |
'Authorization': 'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' | |
}; | |
var request = http.MultipartRequest('GET', Uri.parse('https://pesapedia.co.ke/api/v2/hello')); | |
request.headers.addAll(headers); | |
http.StreamedResponse response = await request.send(); | |
if (response.statusCode == 200) { | |
print(await response.stream.bytesToString()); | |
} | |
else { | |
print(response.reasonPhrase); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"bytes" | |
"mime/multipart" | |
"net/http" | |
"io/ioutil" | |
) | |
func main() { | |
url := "https://pesapedia.co.ke/api/v2/hello" | |
method := "GET" | |
payload := &bytes.Buffer{} | |
writer := multipart.NewWriter(payload) | |
err := writer.Close() | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
client := &http.Client { | |
} | |
req, err := http.NewRequest(method, url, payload) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
req.Header.Add("Authorization", "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e") | |
req.Header.Set("Content-Type", writer.FormDataContentType()) | |
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)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myHeaders = new Headers(); | |
myHeaders.append("Authorization", "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e"); | |
var formdata = new FormData(); | |
var requestOptions = { | |
method: 'GET', | |
headers: myHeaders, | |
body: formdata, | |
redirect: 'follow' | |
}; | |
fetch("https://pesapedia.co.ke/api/v2/hello", requestOptions) | |
.then(response => response.text()) | |
.then(result => console.log(result)) | |
.catch(error => console.log('error', error)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var form = new FormData(); | |
var settings = { | |
"url": "https://pesapedia.co.ke/api/v2/hello", | |
"method": "GET", | |
"timeout": 0, | |
"headers": { | |
"Authorization": "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e" | |
}, | |
"processData": false, | |
"mimeType": "multipart/form-data", | |
"contentType": false, | |
"data": form | |
}; | |
$.ajax(settings).done(function (response) { | |
console.log(response); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WARNING: For GET requests, body is set to null by browsers. | |
var data = new FormData(); | |
var xhr = new XMLHttpRequest(); | |
xhr.withCredentials = true; | |
xhr.addEventListener("readystatechange", function() { | |
if(this.readyState === 4) { | |
console.log(this.responseText); | |
} | |
}); | |
xhr.open("GET", "https://pesapedia.co.ke/api/v2/hello"); | |
xhr.setRequestHeader("Authorization", "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e"); | |
xhr.send(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var options = { | |
'method': 'GET', | |
'url': 'https://pesapedia.co.ke/api/v2/hello', | |
'headers': { | |
'Authorization': 'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' | |
}, | |
formData: { | |
} | |
}; | |
request(options, function (error, response) { | |
if (error) throw new Error(error); | |
console.log(response.body); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var axios = require('axios'); | |
var FormData = require('form-data'); | |
var data = new FormData(); | |
var config = { | |
method: 'get', | |
url: 'https://pesapedia.co.ke/api/v2/hello', | |
headers: { | |
'Authorization': 'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e', | |
...data.getHeaders() | |
}, | |
data : data | |
}; | |
axios(config) | |
.then(function (response) { | |
console.log(JSON.stringify(response.data)); | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('follow-redirects').https; | |
var fs = require('fs'); | |
var options = { | |
'method': 'GET', | |
'hostname': 'pesapedia.co.ke', | |
'path': '/api/v2/hello', | |
'headers': { | |
'Authorization': 'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' | |
}, | |
'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); | |
}); | |
}); | |
req.end(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var unirest = require('unirest'); | |
var req = unirest('GET', 'https://pesapedia.co.ke/api/v2/hello') | |
.headers({ | |
'Authorization': 'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' | |
}) | |
.end(function (res) { | |
if (res.error) throw new Error(res.error); | |
console.log(res.raw_body); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$curl = curl_init(); | |
curl_setopt_array($curl, array( | |
CURLOPT_URL => 'https://pesapedia.co.ke/api/v2/hello', | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_ENCODING => '', | |
CURLOPT_MAXREDIRS => 10, | |
CURLOPT_TIMEOUT => 0, | |
CURLOPT_FOLLOWLOCATION => true, | |
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
CURLOPT_CUSTOMREQUEST => 'GET', | |
CURLOPT_HTTPHEADER => array( | |
'Authorization: Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' | |
), | |
)); | |
$response = curl_exec($curl); | |
curl_close($curl); | |
echo $response; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = "https://pesapedia.co.ke/api/v2/hello" | |
payload={} | |
files={} | |
headers = { | |
'Authorization': 'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' | |
} | |
response = requests.request("GET", url, headers=headers, data=payload, files=files) | |
print(response.text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
headers = c( | |
'Authorization' = 'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' | |
) | |
res <- VERB("GET", url = "https://pesapedia.co.ke/api/v2/hello", add_headers(headers), encode = 'multipart') | |
cat(content(res, 'text')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(RCurl) | |
headers = c( | |
"Authorization" = "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e" | |
) | |
res <- getURL("https://pesapedia.co.ke/api/v2/hello", .opts=list(httpheader = headers, followlocation = TRUE)) | |
cat(res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "uri" | |
require "net/http" | |
url = URI("https://pesapedia.co.ke/api/v2/hello") | |
https = Net::HTTP.new(url.host, url.port) | |
https.use_ssl = true | |
request = Net::HTTP::Get.new(url) | |
request["Authorization"] = "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e" | |
form_data = [] | |
request.set_form form_data, 'multipart/form-data' | |
response = https.request(request) | |
puts response.read_body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http --ignore-stdin --form --follow --timeout 3600 GET 'https://pesapedia.co.ke/api/v2/hello' \ | |
\ | |
Authorization:'Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget --no-check-certificate --quiet \ | |
--method GET \ | |
--timeout=0 \ | |
--header 'Authorization: Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e' \ | |
'https://pesapedia.co.ke/api/v2/hello' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment