curl --location 'https://api2.westfax.com/REST/Fax_SendFax/json' \
--header 'Content-Type: multipart/form-data' \
--form 'Username="your_username"' \
--form 'Password="your_password"' \
--form 'ProductId="22222222-1111-0000-0000-000000000"' \
--form 'Numbers1="9702895979"' \
--form 'Files0=@"/Users/doug/Documents/testfax.docx"'
import requestsurl = 'https://api2.westfax.com/REST/Fax_SendFax/json'
data = {
'Username': 'your_username',
'Password': 'your_password',
'ProductId': '22222222-1111-0000-0000-000000000',
'Numbers1': '9702895979'
}
files = {
'Files0': open('/Users/doug/Documents/testfax.docx', 'rb')
}response = requests.post(url, data=data, files=files)
print(response.text)
$ch = curl_init();$data = [
'Username' => 'your_username',
'Password' => 'your_password',
'ProductId' => '22222222-1111-0000-0000-000000000',
'Numbers1' => '9702895979',
'Files0' => new CURLFile('/Users/doug/Documents/testfax.docx')
];curl_setopt_array($ch, [
CURLOPT_URL => 'https://api2.westfax.com/REST/Fax_SendFax/json',
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $data
]);$response = curl_exec($ch);
curl_close($ch);
echo $response;
package mainimport (
"bytes"
"fmt"
"mime/multipart"
"net/http"
"os"
"io"
)func main() {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body) writer.WriteField("Username", "your_username")
writer.WriteField("Password", "your_password")
writer.WriteField("ProductId", "22222222-1111-0000-0000-000000000")
writer.WriteField("Numbers1", "9702895979") file, err := os.Open("/Users/doug/Documents/testfax.docx")
if err != nil {
panic(err)
}
defer file.Close() part, _ := writer.CreateFormFile("Files0", "testfax.docx")
io.Copy(part, file)
writer.Close() req, _ := http.NewRequest("POST", "https://api2.westfax.com/REST/Fax_SendFax/json", body)
req.Header.Set("Content-Type", writer.FormDataContentType()) client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
}
using System;
using System.Net.Http;
using System.IO;
using System.Threading.Tasks;class Program
{
static async Task Main()
{
using var client = new HttpClient();
using var form = new MultipartFormDataContent(); form.Add(new StringContent("your_username"), "Username");
form.Add(new StringContent("your_password"), "Password");
form.Add(new StringContent("22222222-1111-0000-0000-000000000"), "ProductId");
form.Add(new StringContent("9702895979"), "Numbers1"); var filePath = "/Users/doug/Documents/testfax.docx";
var fileStream = File.OpenRead(filePath);
form.Add(new StreamContent(fileStream), "Files0", "testfax.docx"); var response = await client.PostAsync("https://api2.westfax.com/REST/Fax_SendFax/json", form);
string responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}