cURL
curl -X POST -d "fizz=buzz" {{vm.url}}
Python
import requests, time
r = requests.post('{{vm.url}}', data={"ts":time.time()})
print r.status_code
print r.content
Node.js
var request = require('request');
var url ='{{vm.url}}'
request(url, function (error, response, body) {
if (!error) {
console.log(body);
}
});
Ruby
require 'open-uri'
result = open('{{vm.url}}')
result.lines { |f| f.each_line {|line| p line} }
C# / .NET (4.5+)
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace RequestExample
{
class Program
{
static void Main(string[] args)
{
var task = MakeRequest();
task.Wait();
var response = task.Result;
var body = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(body);
}
private static async Task<HttpResponseMessage> MakeRequest()
{
var httpClient = new HttpClient();
return await httpClient.GetAsync(new Uri("{{vm.url}}"));
}
}
Java
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
import java.io.*;
public class RequestTutorial {
public static void main(String[] args) {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("{{vm.url}}");
try {
int statusCode = client.executeMethod(method);
byte[] responseBody = method.getResponseBody();
System.out.println(new String(responseBody));
} catch (Exception e) {
System.err.println("Fatal error: " + e.getMessage());
e.printStackTrace();
} finally {
method.releaseConnection();
}
}
}
PHP
<?php
$result = file_get_contents('{{vm.url}}');
echo $result;
?>